3

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.

Youn Kyu Lee
  • 123
  • 2
  • 6

1 Answers1

2

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;
}
Sujay
  • 3,417
  • 1
  • 23
  • 25