Android Splash activity not redirecting - android

I have created a splash activity for my app. I am trying to redirect from my Splash activity to the Starting Point activity using AndroidManifest.xml but its not working. The Splash class loads up, and then it doesn't redirect to the Starting Point. And it doesn't give any errors either.
So can you please help me figure it out.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myapp.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myapp.StartingPoint"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.myapp.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Now I have also tried
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StartingPoint"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.myapp.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
So what can I do here. I am not getting redirected from Splash to my Starting Point.
Splash Code
package com.example.myapp;
import android.app.Activity;
import android.os.Bundle;
public class Splash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
}
}

Add this code to your Splash.java
Thread timer = new Thread(){
public void run(){
try {
sleep(2000);
} catch (Exception e) {
// TODO: handle exception
} finally{
Intent i = new Intent(Flash_Activity.this, StartingPoint.class);
startActivity(i);
}
}
};
timer.start();
}
You are never calling anything to change the activity from your splash to the starting point. This thread will do that.

Use this easy way to redirect to acitvity
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(this,MainActivity.class);
startActivity(intent);
finish();
}
},2500);

Related

open another activity with a button not working

So when this code runs I get no errors. It displays the buttons correctly and everything, but when I click on the button nothing happens (it just clicks and clicks and clicks nothing happens).
Below I will post the xml manifest so you can see that I have done everything perfectly, but somehow it it is not doing what I am asking it to do.
package com.Tripp.thebasics;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Menu extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.jokecatagories);
//setting up the button references
Button jokeD = (Button) findViewById(R.id.jokeoftheday);
Button jokeC = (Button) findViewById(R.id.jokecatagories);
jokeD.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(getApplicationContext(),JokeOfTheDay.class);
startActivity(i);
}
});
jokeC.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent s = new Intent(".JokeCatagories");
startActivity(s);
}
});
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
}
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Tripp.thebasics"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".Main"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".com.Tripp.thebasics.JokeCatagories"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.JOKECATAGORIES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Sweet"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SWEET" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".com.Tripp.thebasics.JokeOfTheDay"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.JOKEOFTHEDAY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Change your OnClickListeners as follows...
jokeD.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(Menu.this, JokeOfTheDay.class);
startActivity(i);
}
});
jokeC.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent s = new Intent(Menu.this, JokeCatagories.class);
startActivity(s);
}
});
Then get rid of this <intent-filter> from the JokeCategories <activity> section in the manifest...
<intent-filter>
<action android:name="android.intent.action.JOKECATAGORIES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
...and get rid of this one from the JokeOfTheDay <activity> section...
<intent-filter>
<action android:name="android.intent.action.JOKEOFTHEDAY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Basically, don't use the application Context to start an Activity (it's not necessary from an Activity as it has its own Context) and, on the whole, use explicit Intents to start Activities rather than defining <intent-filter> section in the manifest.

Android Title Bar and Icon

When my app starts up i see the title bar and the application name with a white activity.
Even though my mainactivity is a splash screen, it does not start at first, but after 2 seconds of this Title bar and white activity. How do i disable this.
thanks for the help!
Splash.java
`public class Splash extends Activity {
#Override
protected void onCreate(Bundle parameter) {
// TODO Auto-generated method stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
super.onCreate(parameter);
Thread timer= new Thread()
{
#Override
public void run()
{
try
{
//Display for 3 seconds
sleep(3000);
}
catch (InterruptedException e)
{
// TODO: handle exception
e.printStackTrace();
}
finally
{
//Goes to Activity StartingPoint.java(STARTINGPOINT)
Intent openstartingpoint=new Intent("com.vault.beta.MAINACTIVITY");
startActivity(openstartingpoint);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
`
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vault.beta"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="Vault - Login" >
<intent-filter>
<action android:name="com.vault.beta.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Screen"
android:label="Calender" >
<intent-filter>
<action android:name="com.vault.beta.SCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MenuList"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.vault.beta.MENULIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.vault.beta.PASSWORD" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".EditNote"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.vault.beta.EDITNOTE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Remove the theme of the main activity
android:theme="Theme.Holo.NoActionBar"

Android app force closing after splash screen

I have a splash screen with a timer that runs for 3 seconds. After the 3 seconds it is supposed to auto load another activity called Dashboard. I made a new class that I want to have load after the splash screen called WelcomeSplash. I changed the classes in the splash screen from Dashboard to WelcomeSplash and the app force closes and the logcat says it has a null point exception. Here is the snip of code from the splash class and logcat snip.
02-13 23:18:46.826: E/AndroidRuntime(2475): FATAL EXCEPTION: main
02-13 23:18:46.826: E/AndroidRuntime(2475): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.magicbuddy.gamble/com.magicbuddy.gamble.welcomeSplash}:
java.lang.NullPointerException
02-13 23:18:46.826: E/AndroidRuntime(2475): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
Here is the snip of the Splash code
startActivity(new Intent(Splash.this, welcomeSplash.class));
When I change the welcomeSPlash.class to Dashboard.class the app does not force close. Here is the welcomeSplash Activity,
public class welcomeSplash extends Activity implements OnClickListener {
Button btnskip;
Button btnplay;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
btnskip =(Button) findViewById(R.id.btnSkip);
btnskip.setOnClickListener(this);
btnplay =(Button) findViewById(R.id.btnOk);
btnplay.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnSkip:
Intent a = new Intent(welcomeSplash.this, Dashboard.class);
startActivity(a);
break;
case R.id.btnOk:
Intent i = new Intent(welcomeSplash.this, Profile.class);
startActivity(i);
break;
}
}
}
THe manifest is copied below too.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.magicbuddy.gamble"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.magicbuddy.gamble.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.magicbuddy.gamble.welcomeSplash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.magicbuddy.gamble.Dashboard" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.magicbuddy.gamble.Dashboard"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Player"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Menu"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.magicbuddy.gamble.Popup"
android:label="#string/title_activity_popup" >
</activity>
</application>
</manifest>
Remove this code from your menifest
<intent-filter>
<action android:name="com.magicbuddy.gamble.Dashboard" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Activity B starts before Activity A

I was trying to get a small image to show up before my Main Activity starts. This is my current coding in the android manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.test.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
whatever I do, my splash screen does not start. They start separately, but never together, (I still haven't put a timer in my splash image as I want to check whether it works or not and it isn't working)
Remove
<intent-filter>
<action android:name="com.example.test.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Use below code in splash screen after desired time
Intent intent=new Intent(this,MAINACTIVITY.class);
startActivity(intent);
finish(); //To close splashscreen when MAINACTIVITY loads
The above code starts with splash screen and after some time start your main activity
You should remove the <intent-filter> section from your MainActivity declaration ,
and launch the MainActivity from the splashActivity using a simple intent and startActivity call.
Try this.
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity" >
</activity>
</application>
Code for your Splash Class-
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
public class Splash extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{ // TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final Handler handle = new Handler();
Runnable delay = new Runnable() {
public void run() {
startActivity(new Intent(Splash.this, MainActivity.class));
finish();
}
};
handle.postDelayed(delay,5000);
}
}
its delay next intent 5 second. you can set time according to you.
Use This:
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity" >
</activity>
</application>
and This :
public class Splash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
Intent mInHome = new Intent(Splash.this, MainActivity.class);
Splash.this.startActivity(mInHome);
Splash.this.finish();
}
}, 3000);
}
}

My android app can download but doesnt appear in my downloaded apps

My new android app can download from the playstore but doesn't appear in my downloaded apps. When i download it from the play store usually there is an option to 'open' the app aswell as 'uninstall', only the uninstall button is visible. (http://i.imgur.com/jNTvJq2.png notice the missing open button)
here's the my manifest, there were no errors during all the tests i ran.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jackattackapps.bigl"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/iconimage"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<activity
android:name="com.jackattackapps.bigl.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.jackattackapps.bigl.Splashscreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SPLASHSCREEN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
And this is the activity that is supposed to load on the start of the application.
package com.jackattackapps.bigl;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splashscreen extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Thread timer = new Thread(){
public void run(){
try{
MediaPlayer ourSong = MediaPlayer.create(Splashscreen.this, R.raw.splashsound);
ourSong.start();
sleep(2300);
}
catch (InterruptedException e){
e.printStackTrace();
} finally {
Intent openMainActivity = new Intent("android.intent.action.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
if more information is needed just comment, help would be appreciated greatly.
Your Launcher activity should have this Intent Filter
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

Categories

Resources