0

In frist appliaction ,i want use intent to lunach another application's activity class ,and this class is belong another application! them are not in same application. i dont have and not know second application's activity 's action and other value in it's AndroidManifits.xml .

how i fix it? i remember this code could run a week ago ,now it can't...

help

these code could run before some days ago ,but now it can't, because second application had update?, but his class name,package name never changed!

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
        ComponentName apk2Component1 =
                new ComponentName(the second appliaction's package name, the second appliaction's activity class name);
        Intent mIntent = new Intent();
        mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        mIntent.setComponent(apk2Component1);
        startActivity(mIntent);
    }
}

<application
    android:icon="@mipmap/ic_launcher"
    android:label="d"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

java.lang.SecurityException: Permission Denial: starting Intent { cat=[android.intent.category.LAUNCHER] cmp=com.chinarainbow.tft/.mvp.ui.activity.TFTQRActivity } from ProcessRecord{8525c14 17370:com.dqj.tianfu/u0a802} (pid=17370, uid=10802) not exported from uid 10005
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2931)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1620)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6701)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:108)
     Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cat=[android.intent.category.LAUNCHER] cmp=class name } from ProcessRecord{8525c14 17370:com.dqj.tianfu/u0a802} (pid=17370, uid=10802) not exported from uid 10005
        at android.os.Parcel.readException(Parcel.java:1954)
        at android.os.Parcel.readException(Parcel.java:1900)
        at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4465)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
        at android.app.Activity.startActivityForResult(Activity.java:4536)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
        at android.app.Activity.startActivityForResult(Activity.java:4494)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
        at android.app.Activity.startActivity(Activity.java:4855)
        at android.app.Activity.startActivity(Activity.java:4823)
        at com.dqj.tianfu.MainActivity.onCreate(MainActivity.java:20)
        at android.app.Activity.performCreate(Activity.java:7050)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2931) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1620) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:176) 
        at android.app.ActivityThread.main(ActivityThread.java:6701) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:108)
Tiw
  • 4,749
  • 13
  • 21
  • 32
  • 2
    Possible duplicate of [How to start activity in another application?](https://stackoverflow.com/questions/2209513/how-to-start-activity-in-another-application) – MERN May 31 '19 at 18:31

1 Answers1

0

it's possible the app you're launching has disabled the exported flag, which controls whether other apps can launch it. You may want to set that flag to true in the app you're launching:

<service
    android:exported="true"
/>

https://developer.android.com/guide/topics/manifest/service-element#exported

jspcal
  • 47,335
  • 4
  • 66
  • 68
  • thank your help,and it still crach 。i add " android:exported="true"" into the frist application,and still crash,same logcat . you meaning i add android:exported="true" into second applaiction ,but second applaiction is others i dont have his source code – androidMaterial Jun 01 '19 at 13:27