Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch an Android app without "android.intent.category.LAUNCHER"

Tags:

android

I want to know how to launch an Android app without:

android.intent.category.LAUNCHER

Here is my AndroidManifest.xml:

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

If removing line 3, the app will not be in the launcher. The question is: where and how can I launch this app in other way?

like image 293
Richard Ye Avatar asked Sep 14 '11 09:09

Richard Ye


People also ask

What is android intent category default?

category: android.intent.category. DEFAULT. Matches any implicit Intent. This category must be included for your Activity to receive any implicit Intent.

How do I launch an app using package name?

Just use these following two lines, so you can launch any installed application whose package name is known: Intent launchIntent = getPackageManager(). getLaunchIntentForPackage("com. example.

Can we start a service without activity?

Sure! No reason you cannot have an application with only a service. ...and no need to get into AIDL unless you want to. The problem is, how to make the application run. When you create an application with an Activity, you add an Intent filter, in the manifest, that makes the activity startable from the Launcher.

What is intent in android application?

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose.


1 Answers

You'll need to use a BroadcastReceiver.

public class SafetyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        ActivityManager as = (ActivityManager) context
                .getSystemService(Activity.ACTIVITY_SERVICE);
        if (IsNavigationRunning(as)) {
            Intent i = new Intent(context, VoiceActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
    }
}

Manifest:

<application
    android:icon="@drawable/fot"
    android:label="@string/app_name" >
    <activity
        android:name="com.Safety.VoiceActivity"
        android:launchMode="singleTop"
        android:theme="@style/Theme.CompletelyTransparentWindow" >
    </activity>
    <receiver
        android:name="com.Safety.SafetyReceiver"
        android:process=":goodprocess" >
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>
</application>

This is an example that starts when a text is received.

like image 81
Ryan Avatar answered Nov 10 '22 05:11

Ryan