Sofien Rahmouni
Sofien Rahmouni

Reputation: 4927

About android:launchMode="singleInstance" compatibility

I have used android:launchMode="singleInstance" in my application how compiled & run perfectly in android api 2.3.3 but when i have deployed my application in the android OS which based in api 4.0 ,the intent can't be launched in the background. What is the relation between android launchmode and the version of android api ?

Upvotes: 3

Views: 1937

Answers (1)

Sofien Rahmouni
Sofien Rahmouni

Reputation: 4927

Finally, I have got it working. Following is the solution of my problem.

This is my BroadcastReceiver:

public class BroadcastReceive extends BroadcastReceiver{
    // Display an alert that we've received a message.    
    @Override 
    public void onReceive(Context context, Intent intent){
        Intent i = new Intent(context,CallActivity.class);
        i.setAction(Intent.ACTION_VIEW);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_FROM_BACKGROUND);
        context.startActivity(i);
    }
}

And in manifest.xml:

<activity
    android:name=".callActivity"
    android:label="@string/invite_activity_lbl"
    android:launchMode="singleTask">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    </intent-filter>
</activity>

It's compatible with API level 11 and more

Upvotes: 3

Related Questions