Here is my Home.java code. It is not redirecting to next page, even if I change the intent to (home.this, MainActivity.class):
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Home extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
Thread timer = new Thread() {
public void run() {
try{
sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent openMainActivity = new Intent("com.droid.mine.MainActivity");
startActivity(openMainActivity);
}
}
};
timer.start();}{
}
}
Here is my MainActivity.java code. I.e next page
I am getting the error as ClassCastException:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button log,sign;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
log = (Button) findViewById(R.id.register);
sign = (Button) findViewById(R.id.linktologin);
log.setOnClickListener((OnClickListener) this);
sign.setOnClickListener((OnClickListener) this);
}
public void onClick(View v) {
switch(v.getId()) {
case R.id.register:
break;
case R.id.linktologin:
Intent i = new Intent();
i.setClass(MainActivity.this,Register.class);
startActivity(i);
break;
}
}
}
Manifest is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.droid.mine"
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.droid.mine.Home"
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=".MAINACTIVITY" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is the logcat error:
04-21 15:59:07.156: I/ApplicationPackageManager(21341): cscCountry is not German : INS
04-21 15:59:07.273: D/dalvikvm(21341): GC_EXTERNAL_ALLOC freed 78K, 47% free 2860K/5379K, external 408K/517K, paused 95ms
04-21 15:59:09.648: W/dalvikvm(21341): threadid=9: thread exiting with uncaught exception (group=0x40018578)
04-21 15:59:09.710: E/AndroidRuntime(21341): FATAL EXCEPTION: Thread-10
04-21 15:59:09.710: E/AndroidRuntime(21341): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.droid.mine.MainActivity }
04-21 15:59:09.710: E/AndroidRuntime(21341): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
04-21 15:59:09.710: E/AndroidRuntime(21341): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
04-21 15:59:09.710: E/AndroidRuntime(21341): at android.app.Activity.startActivityForResult(Activity.java:2827)
04-21 15:59:09.710: E/AndroidRuntime(21341): at android.app.Activity.startActivity(Activity.java:2933)
04-21 15:59:09.710: E/AndroidRuntime(21341): at com.droid.mine.Home$1.run(Home.java:21)
Here is my Register.java class
package com.droid.mine;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Register extends Activity implements View.OnClickListener {
Button backlog,regg;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
backlog = (Button) findViewById(R.id.loginn);
regg = (Button) findViewById(R.id.signup);
backlog.setOnClickListener(this);
}
public void onClick (View v)
{
switch(v.getId()) {
case R.id.loginn:
break;
case R.id.signup:
Intent in = new Intent();
in.setClass(Register.this,MainActivity.class);
startActivity(in);
break;
}
}
}
Firstly
Change where you intent with this:
Intent intent = new Intent(Home.this,MainActivity.class);
startActivity(intent);
Secondly
Just update your manifest with this:
<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.droid.mine.Home"
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.droid.mine.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.droid.mine.Register"
android:label="#string/app_name" >
</activity>
</application>
Use this as home activity
package com.example.pms;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.widget.Toast;
public class SplashScreen extends Activity {
/*
* The thread to process splash screen events
*/
private Thread mSplashThread;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// splash screen view
setContentView(R.layout.activity_splash);
final SplashScreen mSplashScreen=this;
/*
* The thread to wait for splash screen events
*/
mSplashThread =new Thread(){
#Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(3000);
}
}
catch(InterruptedException ex){
}
finish();
// Run next activity
startActivity(new Intent(getBaseContext(), MainActivity.class));
new Runnable() {
#Override
public void run() {
mSplashThread.stop();
}
};
}
};
mSplashThread.start();
}
/**
* Processes splash screen touch events
*/
#Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}
you can use this code instead
replace
.MainActivity
with
com.droid.mine.MainActivity
while declaring in Manifest file.
//delay in ms
int DELAY = 1000;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(Home.this,MainActivity.class);
startActivity(intent);
}
}, DELAY);
Change your Intent to:
Intent openMainActivity = new Intent(Home.this, MainActivity.class);
startActivity(openMainActivity);
and in manifest file use:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
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.example.testapp.Home"
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" >
</activity>
</application>
</manifest>
You need to register MainActivity and Register Activity in the manifest:
<activity android:name=".Mainactivity" />
<activity android:name=".Register" />
log.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
});
}
sign.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent i = new Intent();
i.setClass(MainActivity.this,Register.class);
startActivity(i);
});
}
I hope this works:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Home extends Activity{
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
Thread splashTimer = new Thread() {
public void run() {
try {
int splashTimer = 0;
while (splashTimer < 2000) {
sleep(100);
splashTimer = splashTimer + 100;
}
Intent intent;
intent = new Intent(Home.this, MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
Log.d("asd","dasd");
}
finally {
finish();
}
}
};
splashTimer.start();
}
}
Edit: Replace your manifest file with this, now I hope it works:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.droid.mine"
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.droid.mine.Home"
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.droid.mine.MainActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
Related
basically am a java developer but now am developing an android app.In my app i can't redirect to the next page when i click on to SIGN IN button and here is my code
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
public class MainActivity extends ActionBarActivity implements View.OnClickListener {
Button log,sign;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
log = (Button) findViewById(R.id.login);
sign = (Button) findViewById(R.id.signup);
log.setOnClickListener(this);
sign.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()) {
case R.id.login:
break;
case R.id.signup:
Intent open = new Intent("com.example.eblood.Register");
startActivity(open);
break;
}
}
}
}
Here is my next page java code
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Register extends Activity{
Button backlog,regg;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
backlog = (Button) findViewById(R.id.linktologin);
regg = (Button) findViewById(R.id.register);
backlog.setOnClickListener((OnClickListener) this);
}
public void onClick (View v)
{
switch(v.getId()) {
case R.id.register:
break;
case R.id.linktologin:
Intent in = new Intent("com.example.eblood.MainActivity");
startActivity(in);
break;
}
}
}
Here is my manifest code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eblood"
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.eblood.home"
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.eblood.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.eblood.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.eblood.Register"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.REGISTER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
and the error am getting is android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.eblood.Register }
And here is my home.java
package com.example.eblood;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class home extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
Thread timer = new Thread(){
public void run(){
try{
sleep(2000);
} catch (InterruptedException e){
e.printStackTrace();
} finally {
Intent openMainActivity = new Intent("com.example.eblood.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();}{
}
}
Try this..
If you use Intent open = new Intent("com.example.eblood.Register"); you will get ActivityNotFoundException change it as Intent open = new Intent(MainActivity.this,Register.class);
Change this
Intent open = new Intent("com.example.eblood.Register");
startActivity(open);
to
Intent open = new Intent(MainActivity.this,Register.class);
startActivity(open);
also
change this
Intent in = new Intent("com.example.eblood.MainActivity");
startActivity(in);
to
Intent in = new Intent(Register.this,MainActivity.class);
startActivity(in);
EDIT
Change this.
Intent openMainActivity = new Intent("com.example.eblood.MAINACTIVITY");
startActivity(openMainActivity);
to
Intent openMainActivity = new Intent(home.this,MainActivity.class);
startActivity(openMainActivity);
I have program that has splassh page I used intent to pass splash activity to my main activity folder but when I run my program it stop after my splash
and here is my splash class and manıfest xml and my logcat
package com.tesbih;
import android.app.Activity;
import android.content.Intent;
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);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e .printStackTrace();
}finally{
Intent openStartingPoint = new Intent ("com.tesbih.TESBIHMAINACTIVITY");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
}
and following my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tesbih"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.tesbih.TesbihMainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TESBIHMAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.tesbih.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>
</application>
</manifest>
moreover here is my logcat
02-23 20:33:40.713: E/AndroidRuntime(5683)android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.tesbih.TESBIHMAINACTIVITY }
you can copy and paste the that shown in below
package com.tesbih;
import android.R;
import android.app.Activity;
import android.content.Intent;
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);
Thread timer = new Thread(){
public void run(){
try{
sleep(3000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent i = new Intent (Splash.this,TesbihMainActivity.class);
startActivity (i);
}
}
};
timer.start();
}
}
start your activity like this,
Intent openStartingPoint = new Intent (Splash.this,TesbihMainActivity.class);
startActivity(openStartingPoint);
instead of Timer, you can use handler for splash as well.
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashScreen.this, TesbihMainActivity.class);
startActivity(i);
// close splash
finish();
}
}, SPLASH_TIME_OUT);
android:name="com.tesbih.TesbihMainActivity"
You have above in manifest so you must change
("com.tesbih.TESBIHMAINACTIVITY"); to ("com.tesbih.TesbihMainActivity"); in splash.java
I'm trying to add splash screen activity to my android application, I'm doing everything what I saw on lessons on the internet but it doesn't work. It always say "unfortunately, * has stopped." What can be the reason?
Thanks..
my main activity
<code>package com.fckirbay.istatistikelkitap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.acilis);
Thread thread = new Thread() {
#Override
public void run() {
try {
synchronized (this) {
wait(4000);
}
} catch (InterruptedException e) {
// Hata yönetimi
} finally {
finish();
// Yeni açılmak istenen Intent
Intent intent = new Intent();
intent.setClass(getApplicationContext(), acilis.class);
startActivity(intent);
}
}
};
// Thread başlatılıyor
thread.start();
}
}</code>
mysplash screen
package com.fckirbay.istatistikelkitap;
import com.fckirbay.istatistikelkitap.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class acilis extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button tablolar=(Button)findViewById(R.id.tablolar);
Button istatistikciler=(Button)findViewById(R.id.istatistikciler);
Button unite1=(Button)findViewById(R.id.unite1);
Button unite2=(Button)findViewById(R.id.unite2);
Button unite3=(Button)findViewById(R.id.unite3);
Button unite4=(Button)findViewById(R.id.unite4);
Button unite5=(Button)findViewById(R.id.unite5);
Button unite6=(Button)findViewById(R.id.unite6);
Button devam=(Button)findViewById(R.id.devam);
devam.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.EKRANIKI"));
}
});
tablolar.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.TABLOLAR"));
}
});
istatistikciler.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.ISTATISTIKCILER"));
}
});
unite1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE1"));
}
});
unite2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE2"));
}
});
unite3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE3"));
}
});
unite4.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE4"));
}
});
unite5.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE5"));
}
});
unite6.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fckirbay.istatistikelkitap.UNITE6"));
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
and activity manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fckirbay.istatistikelkitap"
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.fckirbay.istatistikelkitap.MainActivity"
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.fckirbay.istatistikelkitap.acilis"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.ACILIS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
in your manifest file the application entry point should be MainActivity.
should have something that looks like this in your manifest file.
<activity
android:name="com.example.MainActivity"
android:label="#string/app_name" android:screenOrientation="landscape" android:configChanges="keyboard|keyboardHidden|orientation" android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
ok try this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fckirbay.istatistikelkitap"
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.fckirbay.istatistikelkitap.MainActivity"
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="Acilis" />
</activity>
</application>
</manifest>
Problem is you have defined two launcher activities. Make your Splash activity your LAUNCHER and your MainActivity DEFAULT.
For your Splash Activity:
<category android:name="android.intent.category.LAUNCHER"
For your Main Activity:
<category android:name="android.intent.category.DEFAULT"
Can someone please help. After the splash activity, the main activity isn't opening up. But if I put in any other intent filter name it works Just not the main activity. Thanks in advance!
SPLASH ACTIVITY:
package com.hellhog.tfreqpro;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class Splash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.splash);
MediaPlayer mp = MediaPlayer.create(Splash.this, R.raw.smusic);
mp.start();
Thread pro = new Thread(){
public void run(){
try{
sleep(6000);
}catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent yo = new Intent ("android.intent.action2.MAINACTIVITY");
startActivity(yo);
}
}
};
pro.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
MAIN ACTIVITY:
package com.hellhog.tfreqpro;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class MainActivity extends Activity{
Button a, c;
Intent b, d;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
a= (Button) findViewById(R.id.tacan);
c= (Button) findViewById(R.id.flp);
a.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
b = new Intent ("android.intent.action.CONVERTER");
startActivity(b);
}
});
c.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
d = new Intent ("android.intent.action.NEWFLP");
startActivity(d);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hellhog.tfreqpro"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.hellhog.tfreqpro.Splash"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.hellhog.tfreqpro.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action2.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.hellhog.tfreqpro.Converter"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.CONVERTER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.hellhog.tfreqpro.Flightplan"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.FLIGHTPLAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.hellhog.tfreqpro.NewFLP"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.NEWFLP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Try this in your Splash Activity..
Intent yo = new Intent (Splash.this, MainActivity.class);
startActivity(yo);
In your manifest file
<activity
android:name="com.hellhog.tfreqpro.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action2.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
delete the following lines of intent filtter
<intent-filter>
<action android:name="android.intent.action2.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Here is what working for me perfectly !
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.splashscreen);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
}
private class IntentLauncher extends Thread {
#Override
/**
* Sleep for some time and than start new activity.
*/
public void run() {
try {
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
// Start main activity
Intent intent = new Intent(SplashActivity.this,FullscreenActivity.class);
SplashActivity.this.startActivity(intent);
SplashActivity.this.finish();
}
}
Try to use below code..
public class SplashScreenextends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// TODO Auto-generated method stub
finish();
Intent menu = new Intent(getBaseContext(), MainActivity.class);
startActivity(menu);
}
}, 3000);
}
}
It will set your SplashScreen for 3 seconds and then starts your mainactivity or whatever activity you want to start.MAy it helps you..
I am having an issue with loading up a new intent after my splash screen. I have looked at questions relating to this exception but they all seem to be dealing with thing like google play or google maps not being referenced correctly this is not the case for me.
These are the related questions I have looked at
Not found activity to handle intent?
activity not found to handle intent
no activity found to handle intent
Below is my manifest code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.main"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<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=".HomePage"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.HOMEPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".OrderPlaced"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.ORDERPLACED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Here is the code for the class splash
package com.android.main;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(1000);
}catch(InterruptedException e) {
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.android.main.HOMEPAGE");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
#Override
protected void onPause() {
super.onPause();
finish();
}
}
And here is the class HomePage I am trying to load after the splash screen
package com.android.main;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
public class HomePage extends Activity {
/** Called when the activity is first created. */
TextView name;
EditText editName;
TextView drinks;
Spinner drinksSpinner;
TextView message;
CheckBox checkbox;
Button createOrderButton;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
createOrder();
}
public void createOrder(){
createOrderButton = (Button) findViewById(R.id.bCreateOrder);
createOrderButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
postInformationtoAPI();
}
private void postInformationtoAPI() {
goToOrderCompleted();
}
private void goToOrderCompleted() {
Intent intent = new Intent(HomePage.this , OrderPlaced.class);
HomePage.this.startActivity(intent);
Log.i("onClick", "trying to start new activity to change layout");
}
});
}
}
The app force quits after loading the splash screen and gives the following exception
03-14 22:32:33.553: E/AndroidRuntime(3166): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.main.HOMEPAGE }
Any help with this would be greatly appreciated
You have to differentiate the Intent's Constructor,
Intent openStartingPoint = new Intent("com.android.main.HOMEPAGE");
Which assume com.android.main.HOMEPAGE as Intent's action Filter. Which is not available in your application's android manifest.xml file. You have
<action android:name="android.intent.action.HOMEPAGE" />
which should be,
<action android:name="com.android.main.HOMEPAGE" />
OR just change it with,
Intent openStartingPoint = new Intent(Splash.this, HOMEPAGE.class);
<activity
android:label="#string/app_name"
android:name=".SplashScreen"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.android.main.HOMEPAGE"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter >
<action android:name="com.android.main.HOMEPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Also i would have a timer task to display splash screen
public class SplashScreen extends Activity{
Timer splashTimer;
SplashTimerHandler splashTimerHandler;
private boolean applicationPaused=false;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
this.setSplash();
}
private void setSplash()
{
this.splashTimerHandler=new SplashTimerHandler();
this.splashTimer=new Timer();
this.splashTimer.schedule(this.splashTimerHandler, 0, 1000);
}
#Override
public void onPause()
{
super.onPause();
this.applicationPaused=true;
this.closeSplashTimer();
}
#Override
public void onResume()
{
super.onResume();
if(this.applicationPaused)
{
this.applicationPaused=false;
this.closeSplashTimer();
this.setSplash();
}
}
public class SplashTimerHandler extends TimerTask{
int splashTimerCounter=0;
#Override
public void run()
{
splashTimerCounter++;
if(splashTimerCounter>2)
{
runOnUiThread(splashTimeOver);
}
}
private Runnable splashTimeOver=new Runnable() {
#Override
public void run()
{
closeSplashTimer();
startHomeScreen();
}
};
}
protected void closeSplashTimer()
{
if(this.splashTimer!=null)
{
this.splashTimer.cancel();
this.splashTimer=null;
}
}
private void startHomeScreen()
{
this.closeSplashScreen();
startActivity(new Intent("com.android.main.HOMEPAGE"));
}
private void closeSplashScreen()
{
this.closeSplashTimer();
this.finish();
}
#Override
public boolean onKeyDown(int keycode, KeyEvent event)
{
if(keycode==KeyEvent.KEYCODE_BACK)
{
this.closeSplashScreen();
}
return true;
}
}