0
A
回答
0
0
package com.demo.example.ShareService;
interface IShareService {
boolean isSameProcess(int clientPid);
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pluralsight.example.ShareService"
android:sharedUserId="demo.example.ShareServiceUser">
<uses-sdk android:minSdkVersion="17"
android:targetSdkVersion="19"/>
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:process="demo.example.ShareServiceProcess" >
<service android:name=".ShareServiceSample"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.ACTION_MAIN" />
<action android:name="android.intent.action.RUN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
</application>
</manifest>
package com.demo.example.ShareService;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Process;
import android.util.Log;
public class ShareServiceSample extends Service {
private static final String LOG_TAG = "ShareServiceSample";
private ShareServiceImpl mBinder = new ShareServiceImpl();
public IBinder onBind(Intent intent) {
Log.d(LOG_TAG, "Intent: " + intent.toString() + ", return binder " + mBinder.toString());
return mBinder;
}
@Override
public void onCreate() {
super.onCreate();
}
private class ShareServiceImpl extends IShareService.Stub {
public boolean isSameProcess(int clientPid) {
boolean same;
same = (clientPid == Process.myPid());
Log.d(LOG_TAG,
"Client PID/Service PID: " +
Integer.toString(clientPid) +
"/" +
Integer.toString(Process.myPid()));
return same;
}
}
}
相關問題
- 1. 如何將共享庫與其他共享庫鏈接到Linux?
- 2. 共享主機與服務
- 3. 與其他類共享對象?
- 4. C++ ::與所有其他類共享類
- 5. 服務共享
- 6. 將共享庫與其他共享庫鏈接是否好?
- 7. C++共享庫創建 - 與其他共享庫鏈接
- 8. 如何讓其他xgsubmitted任務與Visual Studio構建任務共享cpus?
- 9. 如何實現邀請碼與其他用戶共享資源?
- 10. 如何與其他用戶共享張量權重
- 11. Android - 如何與其他應用程序共享聲音文件
- 12. 如何與其他活動共享對象?
- 13. 如何與其他用戶使用Parse with iOS共享對象?
- 14. Google firebase - 如何與其他應用程序共享數據庫
- 15. 你如何與其他開發者共享你的git倉庫?
- 16. 如何與其他人共享xCode .app產品
- 17. Android共享服務?
- 18. 文件從管理界面一臺服務器到其他域
- 19. 錯誤在共享服務器與MySQL
- 20. 與WCF服務共享枚舉
- 21. 與WCF服務共享域模型
- 22. 與WCF服務共享事件
- 23. Azure CDN與共享託管服務器
- 24. 與Internet共享Apache服務器?
- 25. WCF與服務共享模型
- 26. 如何共享託管服務器
- 27. 如何通過XRM服務共享CRM2011?
- 28. 如何共享服務 - NgModule - Angular2
- 29. OpenStack API服務如何與其他服務進行通信?
- 30. 與其他組件或服務分享observables