I just started playing with services in Android and I am trying to make a hidden app which mutes the phone on startup. I was following this thread:Android hidden application
It doesn't show any errors but the service doesn't semm to be called on startup.
This is my Android/manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<receiver android:name="org.example.timer.serviceCode" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="org.example.timer.service" />
</application>
Also my serviceCode:`
package com.example.timer;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class serviceCode extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent("com.example.service");
i.setClass(context, serviceCode.class);
context.startService(i);
}
}
And my service:
package com.example.timer;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.os.IBinder;
public class service extends Service {
private AudioManager myAudioManager;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
super.onCreate();
myAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
myAudioManager.setStreamMute(AudioManager.STREAM_ALARM, true);
myAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
myAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
myAudioManager.setStreamMute(AudioManager.STREAM_RING, true);
myAudioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
}
}
I am kinda confused becouse I was following the guide and nothing happens. When I turn on the phone the sound is on the same value. I also tried putting there toast to find out whether the service even starts but it didn't show up.
My LogCat:
[2014-09-06 16:13:46 - timer] ------------------------------
[2014-09-06 16:13:46 - timer] Android Launch!
[2014-09-06 16:13:46 - timer] adb is running normally.
[2014-09-06 16:13:46 - timer] No Launcher activity found!
[2014-09-06 16:13:46 - timer] The launch will only sync the application package on the device!
[2014-09-06 16:13:46 - timer] Performing sync
[2014-09-06 16:13:47 - timer] Uploading timer.apk onto device '0c295416'
[2014-09-06 16:13:47 - timer] Installing timer.apk...
[2014-09-06 16:13:49 - timer] Success!
[2014-09-06 16:13:49 - timer] \timer\bin\timer.apk installed on device
[2014-09-06 16:13:49 - timer] Done!
Thank you for help.