Доброго времени суток! Делаю в Qt приложение под андроид. Сейчас решил попробовать сделать сервис в андроид студио и запустить его с моего приложения, но получил ошибку.
Вот код сервиса:
| Код | public class MyService extends Service { public MyService() { Log.d("MyService", "Starrrrrrrrrrrrrrrrrrrt"); } @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException("Not yet implemented"); } }
|
Манифест:
| Код | <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example2.admin.myservice"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <service android:name="com.example2.admin.myservice.MyService" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="com.example2.admin.myservice.MyService"/> </intent-filter> </service> </application> <uses-permission android:name="android.permission.INTERNET"/> </manifest>
|
А вот так со стороннего приложения запускаю сервис:
| Код | Intent intent = new Intent(); intent.setComponent(new ComponentName("com.example2.admin.myservice", "com.example2.admin.myservice.MyService")); startService(intent);
|
Подскажите, пожалуйста, что я делаю не правильно?
Спасибо! |