私の問題は質問のタイトルにあります。ログインするだけで簡単なサービスを開始/バインドしようとしていますが、まったく機能していません。Service Connexion メソッドでやりたい:
public class testServiceBound extends Service {
/**
* PRIVATE ATTRIBUTES
*/
// log
private static final String TAG = testServiceBound.class.getSimpleName();
private final Binder _binder = new testBinder();
@Override
public void onCreate() {
Log.i(TAG, "onCreate--");
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand--");
return START_STICKY;
}
@Override
public void onDestroy() {
Log.i(TAG, "onDestroy--");
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
Log.i(TAG, "onBind--");
return _binder;
}
public class testBinder extends Binder {
public testServiceBound getServiceInstance() {
Log.i(TAG, "PlayerBinder--getServiceInstance--");
return testServiceBound.this;
}
}
}
活動中:
private testServiceBound _testService;
public final ServiceConnection _connectionStreamingtest = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder testBinder) {
Log.i(TAG, "onServiceConnected--");
// service
testBinder binder = (testBinder) testBinder;
_testService = binder.getServiceInstance();
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
Log.i(TAG, "onServiceDisconnected--");
_bound = false;
}
};
public void bindToService() {
Log.i(TAG, "bindToService--");
Intent intenttest = new Intent(MainActivity.this, testServiceBound.class);
startService(intenttest);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "onCreate--");
//
// service
bindToService();
}
マニフェストで:
<service
android:name="com.egdigital.testing.service.testServiceBound"
android:enabled="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
</service>
そして私もこれで試しました
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
エラーなし、ログなし、何も起こりません..