2017年6月15日 星期四

Android 在別的畫面(app) 去呼叫特定已開啟的App

AndroidMainfest.xml
-------------------
<activity    android:name=".main.Activity1"   
 android:configChanges="keyboard|keyboardHidden|orientation"
 android:label="@string/app_name"   
 android:screenOrientation="portrait"
  android:launchMode="singleInstance" <= 此行絕對不能加,會造成呼叫其他的app
> <!-- Prevents authorization dialog from closing when screen orientation is changed -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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


-------------------
可用BroadcastReceiver來收到廣播,再行處理,此方法每次呼叫 不會onCreate其activity

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.captain.voice.alexa.mobile", 
"com.captain.voice.alexa.mobile.main.Audio_Record"));
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

沒有留言:

張貼留言