from my application i’m trying to open another one, using this code:
package com.copag.lanceappli;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
public class LanceAppli extends Activity {
public void LanceAppli() {
try
{
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory("android.intent.category.LAUNCHER");
intent.setComponent(new ComponentName("test.test.test","test.test.test.MainActivity"));
startActivity(intent);
}
catch( ActivityNotFoundException e)
{
e.printStackTrace();
}
catch( Exception e)
{
e.printStackTrace();
}
}
public void main (String [] args)
{
LanceAppli();
}
}
what happens is that the application crushs… with no error message.
here is what i get:
any ideas?
The problem is that I’ve tried to use the
intentdirectly on the constructor as David said. So I’ve changed it to:So I put the code into
onCreateas it should be and it’s working!