【问题标题】:android location app that calls an activity at a point of interest在兴趣点调用活动的 android 位置应用程序
【发布时间】:2014-03-01 12:22:08
【问题描述】:

我们正在开发一个 Android 应用项目,该项目直接在不同的兴趣点调用 Activity(我们知道这是不可取的),即使应用没有运行 .我们已经做了一些事情,但是指定的 Activity 没有在指定的 POI 处被调用。任何帮助..这是两个 POI 的代码。

import android.location.LocationListener;
import android.location.LocationManager;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.view.Window;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    LocationManager lm;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);




        PendingIntent pendingIntent1 = PendingIntent.getActivity(this,0, new Intent (this, SecondActivity.class),0);
        PendingIntent pendingIntent2 = PendingIntent.getActivity(this,0, new Intent (this, ThirdActivity.class),0);


         lm.addProximityAlert(3.867247, 11.496267, 20, -1, pendingIntent1); 
        lm.addProximityAlert(3.8626208, 11.495961, 20, -1, pendingIntent2);  
    }



}

【问题讨论】:

  • 你能发布你的 logcat 的输出吗?
  • 好的,感谢您回答@ACengiz,这只是 logcat 的一部分。希望它可以帮助您帮助我:) '02-05 13:16:58.673: I/ProgramMonitor(3640): cpu_usage_wan 02 -05 13:16:59.306:I/StatusBarPolicy(1561):BAT。 S:2 H:2'
  • Logcat 输出不足以让我评论问题。这里没有错误信息。
  • ok @ACengiz ..这是我得到的错误 logcat '02-05 17:45:42.388: E/GlsClient-query(1568): at com.google.common.async 的一部分.AsyncHttpRequestFactory.run(未知来源)02-05 17:45:42.388:E/GlsClient-query(1568):在 com.google.common.lang.BaseThreadFactory$ThreadImpl.run(未知来源)02-05 17:45 :42.638: E/PlayEventLogger(2437): 上传失败类 java.net.UnknownHostException(play.googleapis.com) 02-05 17:45:44.044: E/SensorManager(2186): unregisterListener:: all sensor, listener = com .twtdigital.zoemob.api.dataAcquirer.a@4076dca8 '
  • 嗨 Alain 很抱歉我的回复晚了,但我还没有找到具体的答案。原因可能是您的清单文件中的应用程序权限或取消注册传感器的问题。

标签: android android-activity location android-location point-of-interest


【解决方案1】:

在添加接近警报之前尝试注册位置更新:

lm.requestLocationUpdates(...)

还要确保您已启用AndroidManifest.xml 文件的位置权限:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-13
    • 1970-01-01
    • 2018-01-18
    • 2015-11-12
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多