如何推出一个Android应用程序,而不" android.intent.category.LAUNCHER"而不、应用程序、QUOT、Android

2023-09-05 09:40:51 作者:安然.

我想知道如何启动一个 Android应用无:

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

android.intent.category.LAUNCHER

android.intent.category.LAUNCHER

下面是我的的Andr​​oidManifest.xml

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

如果除去3号线,应用程序将不会在启动。现在的问题是:在哪里?我怎么能推出其他方式这个应用程序

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?

推荐答案

您将需要使用的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);
        }
    }
}

<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.