小编tom*_*mmy的帖子

Android - 绑定到服务

嗨:我似乎无法将活动绑定到同一个包中的服务.

活动如下:

public class myApp extends TabActivity {
    static private String TAG = "myApp";
    private myService mService = null;
    private ServiceConnection mServiceConn = new ServiceConnection(){
        public void onServiceConnected(ComponentName name, IBinder service) {
            Log.v(TAG, "Service: " + name + " connected");
            mService = ((myService.myBinder)service).getService();
        }

        public void onServiceDisconnected(ComponentName name) {
            Log.v(TAG, "Service: " + name + " disconnected");
        }
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        doBind();
        Log.i(TAG, "Started (UI Thread)"); …
Run Code Online (Sandbox Code Playgroud)

android android-service

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

android-service ×1