From my own Android app, I'm trying to launch an external app's component explicitly.
Intent i = new Intent();
Uri uri = Uri.parse("http://0.0.0.1");
i.setData(uri);
i.setComponent(new ComponentName("other.app.android","other.app.android.Activity1"));
startActivity(i);
Can I replace i.setComponent(...)
to i.setClassName("other.app.android", other.app.android.Activity1")
?
Please let me know what is the difference between them.
Yes, you can do that. Internally setClassName(String, String)
creates a new ComponentName(String, String)
public Intent setClassName(String packageName, String className) {
mComponent = new ComponentName(packageName, className);
return this;
}