pramod.deore
Newbie
Hello everybody, In my application I want to send sms, but the application must have to run in the background. It send the sms but it is not run in the background. I have following code.
//Background.java
My Service class look like this
//MyService.java
//AndroidManifest.xml
But when I run it It is not running in the background.
Thanks
//Background.java
Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]package[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] com.micro;
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.app.Activity;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.Intent;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.os.Bundle;
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Background [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Activity {
[/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]/**[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]Called[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]when[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]the[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]activity[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]first[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]created.[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]*/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreate(Bundle savedInstanceState) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onCreate(savedInstanceState);
setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
startService([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], MyService.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]));
}[/LEFT]
}
[/SIZE]
My Service class look like this
//MyService.java
Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]package[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] com.micro;
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.app.Activity;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.app.PendingIntent;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.app.Service;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.BroadcastReceiver;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.Context;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.Intent;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.content.IntentFilter;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]android.media.MediaPlayer[/U];[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.os.IBinder;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.telephony.gsm.SmsManager;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]android.util.Log[/U];[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] android.widget.Toast;
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MyService [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Service
{
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IBinder onBind(Intent intent)
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreate()
{
sendSMS([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"9960510915"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Pramod Deore"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onDestroy()
{
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onStart(Intent intent, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] startid)
{
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sendSMS(String phoneNumber, String message)
{
String SENT = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SMS_SENT"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String DELIVERED = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SMS_DELIVERED"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
PendingIntent sentPI = PendingIntent.[I]getBroadcast[/I]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0,[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.[I]getBroadcast[/I]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0,[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent(DELIVERED), 0);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//---when the SMS has been sent---[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]registerReceiver([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BroadcastReceiver(){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onReceive(Context arg0, Intent arg1)
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]switch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (getResultCode())
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Activity.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_OK[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SMS sent"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SmsManager.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_ERROR_GENERIC_FAILURE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Generic failure"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SmsManager.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_ERROR_NO_SERVICE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"No service"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SmsManager.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_ERROR_NULL_PDU[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Null PDU"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SmsManager.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_ERROR_RADIO_OFF[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Radio off"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
}
}, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IntentFilter(SENT));
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//---when the SMS has been delivered---[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]registerReceiver([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BroadcastReceiver()
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onReceive(Context arg0, Intent arg1)
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]switch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (getResultCode())
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Activity.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_OK[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SMS delivered"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Activity.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_CANCELED[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
Toast.[I]makeText[/I](getBaseContext(), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SMS not delivered"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],Toast.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]LENGTH_SHORT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).show();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
}
},[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IntentFilter(DELIVERED));
SmsManager sms = SmsManager.[I]getDefault[/I]();
sms.sendTextMessage(phoneNumber, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], message, sentPI, deliveredPI);
}
}[/LEFT]
[/SIZE]
//AndroidManifest.xml
Code:
[SIZE=2][LEFT]<?[U]xml[/U] version="1.0" encoding="[U]utf[/U]-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="[U]com[/U].[U]micro[/U]"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="[U]@drawable[/U]/icon" android:label="@string/app_name">
<activity android:name=".Background"
android:label="@string/app_name">
<intent-filter>
<action android:name="[U]android[/U].intent.action.MAIN" />
<category android:name="[U]android[/U].intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:enabled="true" android:name=".MyService" />
</application>
<uses-[U]sdk[/U] android:minSdkVersion="3" />
<uses-permission android:name="[U]android[/U].permission.SEND_SMS">
</uses-permission>
<uses-permission android:name="[U]android[/U].permission.RECEIVE_SMS">
</uses-permission>
[/LEFT]
</manifest>
[/SIZE]
But when I run it It is not running in the background.
Thanks