Android: Starting An Activity For A Different Third Party App

前端 未结 1 1149
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 10:36

I\'m working on an app and I want to integrate the Last.fm app into it. Basically, when someone is looking at an artist in my app, I would like to have a button that they ca

相关标签:
1条回答
  • 2020-11-30 11:11

    Yes, it's possible but you need to know the correct component name. Launch the last.fm app regularly and check the logfile for the cmp=... information that's been used when the app is started. Use this as well in your app then.

    I start the Z-DeviceTest app from the market from within my app without a problem like this:

    final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");                
    intentDeviceTest.setComponent(new  ComponentName("zausan.zdevicetest","zausan.zdevicetest.zdevicetest"));
    startActivity(intentDeviceTest);
    

    in my case the info I took from the logcat was:

    // dat=content://applications/applications/zausan.zdevicetest/zausan.zdevicetest.zdevicetest

    // cmp=zausan.zdevicetest/.zdevicetest

    in order to know how to start the app with the right component/class... do the same for the last.fm app

    Edit: I've tested to launch Last.fm from my own app, and this works fine without any errors:

    final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");                
    intentDeviceTest.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm"));
    startActivity(intentDeviceTest);
    
    0 讨论(0)
提交回复
热议问题