I’m learning android and in a tutorial, to open a new screen they use
…
startActivity( new Intent("com.rob.minispy.sweet"));
( in main.java )
…
public class sweet extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
}
}
( in sweet.java )
…
and finally
<activity android:name=".sweet"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.SWEET" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
( in the manifest )
now not only that it doesn’t really work and make the app crash, wouldn’t it be easier to do it simply by
setContentView(R.layout.splash);
from main.java or are there some downsides to that?
Thanks!
You have 2 ways to start the
sweetactivitystartActivity( new Intent("com.rob.minispy.sweet"));tostartActivity( new Intent("android.intent.action.SWEET"));See more info herestartActivity(new Intent(this,sweet.class)); . This uses the formIntent(Context packageContext, Class<?> cls). More info here