开发者

How to start and switch applications(APK) from a remote service?

开发者 https://www.devze.com 2023-04-03 19:42 出处:网络
I have two application and a remote service.. The remote service is subscribing to http server... Now based on the web servers response i need to start or switch application.

I have two application and a remote service.. The remote service is subscribing to http server... Now based on the web servers response i need to start or switch application.

Is it possible to directly trigger activity intents from remote service?? or should i have to create a broadcast receiver in both application and send signal from my remote service???

SOLUTION: Intent filter added to app manifest say

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="ApplicationActivity134.android.intent.action" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

In your remote service add the intent trigger

Intent i = new Intent("ApplicationActivity134.android.开发者_如何学编程intent.action");
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try{
    this.startActivity(i); 
    }catch(ActivityNotFoundException e){
        Log.v(TAG, "ActivityNotFoundException @ Activity Invoking, Exception: "+e.getMessage());
    }


Yes. It possible.

You must specify additional intent-filter for MAIN (activity which started when you click to app icon) activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号