小编Gor*_*čić的帖子

当我在我的服务中的onStartCommand()中运行while循环时,应用程序没有响应

这是我的代码:

 @Override
public void onCreate() {
    super.onCreate();
    //Log.i("TAG", "ovdje smo");
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("alo", "bre");
     telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
     cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
    oldCellID = cellLocation.getCid();

    while( true ){
        Log.i("jesmo li tu",""+oldCellID);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        Toast.makeText(this, "Kupimo cell ID OLD" + oldCellID, Toast.LENGTH_SHORT).show();
        telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
        newCellID = cellLocation.getCid();

        if(oldCellID != newCellID){
            //TODO uzmi lokaciju + spremi u bazu
            Log.i("usli u petlju", …
Run Code Online (Sandbox Code Playgroud)

android listener android-intent

0
推荐指数
1
解决办法
235
查看次数

标签 统计

android ×1

android-intent ×1

listener ×1