Android explicit intent with target component

后端 未结 5 1477
鱼传尺愫
鱼传尺愫 2020-12-09 03:45

Is it possible to fire explicit intent but not for an activity from my project but for activity in some other application.

I am sure of this code and I know it is ru

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 04:36

    Yes it's possible. But the intent creation is a little different.

    Intent intent = new Intent();
    intent.setComponent(new ComponentName("The package name of the activity that you wish to launch","Its fully qualified class name"));
    startActivity(intent);
    

    But, then you just can't call any activity of any random app. That particular activity should have an intent-filter with a MAIN action.

提交回复
热议问题