Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有可能让Android应用程序没有任何活动,但只提供服务?_Android_Android Service_Android Service Binding - Fatal编程技术网

有没有可能让Android应用程序没有任何活动,但只提供服务?

有没有可能让Android应用程序没有任何活动,但只提供服务?,android,android-service,android-service-binding,Android,Android Service,Android Service Binding,如何使应用程序不包含作为主启动器的活动,但包含作为主启动器的服务?是的,这是可能的。只要不要在你的AndroidManifest中定义任何活动,你就没事了 然而,为了让您的服务能够被呼叫,您应该做的是用广播接收器收听一些电话操作 大概是这样的: <receiver android:name="com.example.MyBroadcastReceiver"> <intent-filter> <action androi

如何使应用程序不包含作为主启动器的
活动,但包含作为主启动器的服务?

是的,这是可能的。只要不要在你的AndroidManifest中定义任何活动,你就没事了

然而,为了让您的服务能够被呼叫,您应该做的是用广播接收器收听一些电话操作

大概是这样的:

    <receiver android:name="com.example.MyBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
        </intent-filter>
    </receiver>
public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Do  your work here...
    }
}

所有将被触发的服务也应该在清单中定义!别忘了

是的,这是可能的。只要不要在你的AndroidManifest中定义任何活动,你就没事了

然而,为了让您的服务能够被呼叫,您应该做的是用广播接收器收听一些电话操作

大概是这样的:

    <receiver android:name="com.example.MyBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
        </intent-filter>
    </receiver>
public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Do  your work here...
    }
}

所有将被触发的服务也应该在清单中定义!别忘了

是的,这是可能的。只要不要在你的AndroidManifest中定义任何活动,你就没事了

然而,为了让您的服务能够被呼叫,您应该做的是用广播接收器收听一些电话操作

大概是这样的:

    <receiver android:name="com.example.MyBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
        </intent-filter>
    </receiver>
public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Do  your work here...
    }
}

所有将被触发的服务也应该在清单中定义!别忘了

是的,这是可能的。只要不要在你的AndroidManifest中定义任何活动,你就没事了

然而,为了让您的服务能够被呼叫,您应该做的是用广播接收器收听一些电话操作

大概是这样的:

    <receiver android:name="com.example.MyBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
        </intent-filter>
    </receiver>
public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Do  your work here...
    }
}
所有将被触发的服务也应该在清单中定义!别忘了

可能的重复可能的重复可能的重复可能的重复