Android 未创建的全局进程中的服务
我正在创建一个服务,将有多个应用程序与该服务对话。因此,我希望服务在全局进程中运行,即进程对任何应用程序都不是私有的。 这是我清单文件的内容Android 未创建的全局进程中的服务,android,android-activity,android-service,Android,Android Activity,Android Service,我正在创建一个服务,将有多个应用程序与该服务对话。因此,我希望服务在全局进程中运行,即进程对任何应用程序都不是私有的。 这是我清单文件的内容 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.username.servicedemo" > <applicati
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.username.servicedemo" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.example.username.servicedemo.FirstService"
android:process="com.example.username.servicedemo.remote"
android:enabled="true"
android:exported="true" >
</service>
</application>
我错过了什么?谢谢 这是一个愚蠢的错误。
服务
创建正确。我正在检查log-inonCreate
方法,但是日志被过滤为只显示选定应用程序中的日志。由于服务
在一个单独的进程中运行,服务
的日志没有出现在logcat中。
我只是换了一个新的过滤器。在这里放一个截图,以防对任何人都有帮助
public void startService (View view) {
int id = android.os.Process.myPid();
Log.i("MYTAG", " process id activity" + Integer.toString(id)
);
Intent intent = new Intent(this,FirstService.class);
intent.putExtra("key","1234");
ComponentName componentName = this.startService(intent);
Log.i("MYTAG",componentName.toString());
}