Android:I / ActivityManager(476):不再需要com.androidLocator.libs(pid 1047):隐藏#16

时间:2011-07-30 21:39:11

标签: java android service toast

我是android的初级开发:) 在我的新应用程序中,我遇到了服务问题,这是我的代码:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.LocationManager;
import android.widget.Toast;


public class OnBootReceiver extends BroadcastReceiver 
{
    private boolean service;
    @Override
    public void onReceive(Context context, Intent intent)
    {

        SharedPreferences settings = context.getSharedPreferences(LbsGeocodingActivity.PREFS_NAME, 0);
        service = settings.getBoolean("service", true);//start 
        Toast.makeText(context, "1", Toast.LENGTH_LONG).show(); 
        if(service)
        {
            Toast.makeText(context, "2", Toast.LENGTH_LONG).show(); 
            Intent i = new Intent(context, Receiver.class);     
            context.startService(i);


        }

    }

}

接收器:

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.os.IBinder;
import android.widget.Toast;

public class Receiver extends Service {
    private MyLocationListener myLocationListener;
    private LocationManager locationManager;

    @Override
    public void onCreate() {
      Toast.makeText(this, "Started", Toast.LENGTH_LONG).show();
          //gps
      myLocationListener=new MyLocationListener(this);

      locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
      locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            LbsGeocodingActivity.MINIMUM_TIME_BETWEEN_UPDATES, 
            LbsGeocodingActivity.MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
            myLocationListener
      );
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }
}

我有这个日志:

I/PackageParser(  476): com.androidLocator.libs: compat added android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_PHONE_STATE
I/ActivityManager(  476): Start proc com.androidLocator.libs for broadcast com.androidLocator.libs/com.androidLocator.OnBootReceiver: pid=1047 uid=10091 gids={3003, 1015}
I/ActivityManager(  476): No longer want com.androidLocator.libs (pid 1047): hidden #16

我看到Toast 1和Toast 2但看不到吐司开始:( 抱歉我的英语不好。

由于

0 个答案:

没有答案