如何通过我的应用程序在另一个应用程序中启动活

时间:2017-06-02 21:54:01

标签: java android android-intent android-activity launching-application

我是非常新的编写Android应用程序,我试图通过我的应用程序(应用程序A)从其他应用程序(应用程序B)启动特定活动。我知道如何启动应用程序B,但是我需要应用程序B通过单击按钮执行某项特定任务而不显示启动过程我只想跳转到该任务(就像播放音乐时显示介绍并启动App B的一部分)。

这是App A的一部分,我想从App B执行特定任务而不是仅启动它。 (甚至可能我不需要发射它)

public void playOn(View view) {

        ImageButton sound = (ImageButton) findViewById(R.id.musicButton);
        if (lightt) {
            sound.setImageResource(R.drawable.play_dn);
            lightt = false;
        } else {
            sound.setImageResource(R.drawable.play_up);
           lightt = true;
        }

       Intent intent = getPackageManager().getLaunchIntentForPackage("com.Zample.RUNiBplayMusic");


        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }

这是我有权访问的应用B的一部分

<application android:icon="@drawable/ic_launcher" android:label="Bplay Music" android:name="com.Zample.RUNiBplayMusic.Common.App" android:theme="@style/AppTheme">
        <activity android:launchMode="singleTask" android:name=".StartActivity" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:host="com.bplaymusicwifi" android:scheme="bplaymu"/>
            </intent-filter>
        </activity>
        <activity android:finishOnTaskLaunch="true" android:name=".HelpListActivity" android:screenOrientation="portrait"/>
        <activity android:launchMode="singleTask" android:name=".DeviceListActivity" android:screenOrientation="portrait"/>
        <activity android:finishOnTaskLaunch="true" android:name=".PlayModeActivity" android:screenOrientation="portrait"/>
        <activity android:finishOnTaskLaunch="true" android:name=".HelpListActivity" android:screenOrientation="portrait"/>
        <receiver android:label="Bplay Music" android:name=".AppWidget.AppWidgetSmall">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
            </intent-filter>
        <receiver android:label="Bplay Music" android:name=".AppWidget.AppWidgetBig">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
            </intent-filter>
            <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info_big"/>
        </receiver>
        <service android:name=".AppWidget.Bplay MusicService"/>
        <service android:name=".Record.RecordService"/>
    </application>

我认为App B中的这部分代码可能对我有所帮助。但我不确定。
我希望你能帮助我解决这个问题。

0 个答案:

没有答案