title: Android-Alert Dialog on location change through service
body: <p>I want to pop up the alert dialog on location change through service. Here i have attached my manifest , Service and broadcastReciever codes.</p>
  
  <p>In the console it is giving that .apk has been installed.</p>
  
  <p>But i'm not getting any toast or alertdialog.</p>
  
  <p>PLease correct me if i'm wrong.</p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.ser"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk android:minSdkVersion="3" /&gt;
  
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" &gt;
  
      &lt;receiver android:name="com.ser.Myreceiver"
          android:permission="android.permission.RECEIVE_BOOT_COMPLETED"&gt;  
  &lt;intent-filter&gt;  
      &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt; 
      &lt;category android:name="android.intent.category.HOME" /&gt;  
  
  &lt;/intent-filter&gt;  
  &lt;/receiver&gt;
  
  
  &lt;service  android:enabled="true" 
      android:name="com.ser.RunService"&gt;
  &lt;intent-filter&gt;  
  &lt;action android:name="android.intent.action.MAIN" /&gt;
  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
  &lt;/intent-filter&gt;
      &lt;/service&gt;    
  
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;`
  </code></pre>
  
  <hr>
  
  <pre><code>package com.ser;
  
  import android.app.AlertDialog;
  import android.app.Service;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.location.Location;
  import android.location.LocationListener;
  import android.os.Bundle;
  import android.os.IBinder;
  import android.widget.Toast;
  
  
  
   public class RunService extends Service implements LocationListener{
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      return null;
  }
  
  @Override
  public void onCreate() {
      // TODO Auto-generated method stub
  
      System.out.println("**inside onCreate");
      super.onCreate();
      Toast.makeText(this, "Service Created", Toast.LENGTH_LONG).show();
      //Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:+5555")); 
      //startActivity(call);
  }
  @Override
  public void onLocationChanged(Location location) {
      // TODO Auto-generated method stub
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage("ALERT")
         .setTitle("Location")
         .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
  
             }
         });
  }
  
  @Override
  public void onProviderDisabled(String provider) {
      // TODO Auto-generated method stub
  
  }
  
  @Override
  public void onProviderEnabled(String provider) {
      // TODO Auto-generated method stub
  
  }
  
  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
      // TODO Auto-generated method stub
  
  }
  
   }
  </code></pre>
  
  <p>//Reciver</p>
  
  <pre><code>package com.ser;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  //import android.widget.Toast;
  //import android.util.Log;
  
  public class Myreceiver extends BroadcastReceiver{
  
  @Override
  public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
      System.out.println("MYRECEIVER");
          //Toast.makeText(Myreceiver.this, "MyReciver",    Toast.LENGTH_SHORT).show();
           Intent serviceLauncher = new Intent(context, RunService.class);
           context.startService(serviceLauncher);
           //Log.v("TEST", "Service loaded at start");
  
  }
  
   }
  </code></pre>