- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在创建实现 LocationListener、GooglePlayServicesClient 的 MainActivity 类,以使用 FusedLocationApi 获取当前位置。它向我显示了一些奇怪的错误,但不会使我的应用程序崩溃,但功能无法正常工作。我正在放置 Log.i() 来检查控制是否进入覆盖的方法,但似乎控制不进入这些方法。下面是代码和输出。请帮忙
public class MainActivity extends FragmentActivity implements
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener, com.google.android.gms.location.LocationListener,android.view.View.OnClickListener
{
private LocationClient mGetLocationLocationClient;
private LocationRequest mGetLocationLocationRequest;
private Location mGetLocationcurrentLocation;
startBtn.setOnClickListener(this);
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Log.i("in onStart", "yes..");
mGetLocationLocationClient.connect();
}
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Log.i("in onLocationChanged", "Yes..");
}
@Override
public void onConnectionFailed(ConnectionResult result) {
// TODO Auto-generated method stub
Log.i("connectionFailed", "yes...shit");
}
@Override
public void onConnected(Bundle connectionHint) {
// TODO Auto-generated method stub
Log.i("in onConnected", "yes..here");
/*
* mGetLocationLocationRequest = LocationRequest.create();
* mGetLocationLocationRequest
* .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
* mGetLocationLocationRequest.setInterval(50);
* mGetLocationLocationClient
* .requestLocationUpdates(mGetLocationLocationRequest, this);
*/
}
@Override
public void onDisconnected() {
// TODO Auto-generated method stub
Log.i("in onDisconnected", "yes..here");
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("in btnClick", "yes..");
if (ok == GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)) {
Log.i("In googpleplayservice", "Available..");
mGetLocationLocationClient = new LocationClient(this, this, this);
mGetLocationLocationClient.connect();
// mGetLocationcurrentLocation =
// mGetLocationLocationClient.getLastLocation();
} else
// Toast.makeText(getApplicationContext(), "Not..available",
// Toast.LENGTH_SHORT).show();
mGetLocationLocationClient.disconnect();
}
这是我的 logcat 输出:
02-23 04:36:06.351: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_ADDED intent due to initialization failure.
02-23 04:36:06.401: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_REPLACED intent due to initialization failure.
02-23 04:37:30.691: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.example.pedometer
02-23 04:37:31.001: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_REMOVED intent due to initialization failure.
02-23 04:37:31.361: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.pedometer
02-23 04:37:31.711: D/PackageBroadcastService(806): Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=com.example.pedometer
02-23 04:37:31.761: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_ADDED intent due to initialization failure.
02-23 04:37:31.781: I/PeopleContactsSync(806): CP2 sync disabled
02-23 04:37:32.341: I/PeopleContactsSync(806): CP2 sync disabled
02-23 04:37:32.411: E/Icing(806): Couldn't handle android.intent.action.PACKAGE_REPLACED intent due to initialization failure.
我不明白为什么它会显示 Intent 问题,我从未使用过它。请任何人都可以帮助我我阅读了很多帖子但没有找到任何答案。
提前致谢
我的 list 文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pedometer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18"
/>
<!-- ACCESS_COURSE_LOCATION FOR RETREIVING LOCATION THROUGH WIFI AND CELL TOWERS
ACCESS_FINE_LOCATION FOR RETREIVING LOCATION THROUGH GPS,WIFI,CELL TOWERS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppBaseTheme"
>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.example.pedometer.MainActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>
</activity>
<activity
android:name="com.example.pedometer.GetLocation"
android:label="@string/app_name"
/>
</application>
</manifest>
最佳答案
您在 MainActivity
的 list 条目中有这个:
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>
为什么会在这里?这是一个广播 Intent,与 Activity
无关。如果您想收听此广播 Intent,您需要在 BroadcastReceiver
中执行此操作。
只需删除它。
关于android - 使用 Fused Location API 检索位置时无法处理 android.intent.package_ADDED 和 REMOVED 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21966927/
我正在尝试在 python 中编写正则表达式来查找目录路径:我的文本如下所示: text = "The public disk is: \\\\diskA\\FolderB\\SubFolderC\\
我想写一个LocationListener,它把最近最精确的位置作为它的位置。我打算在我的 LocationListener 中使用此代码: @Override public void
我想建立一个有光泽和 plotly 的交互式图表。 Shiny 有一个内置功能来获取有关用户交互的信息。比如:input$plot_click、input$plot_dblclick、input$pl
我正在使用 MobileFirst 提供的 WL.Device.Geo.acquirePosition(onGeoLocationSuccess, onGeoLocationFailure, opti
我最近开始使用 ionic 框架,它里面有 angular js。为了在屏幕之间导航,我使用了 $location.path 并且效果很好。但是,在我下载的一个示例中,我看到 $state.go 被用
谁能解释一下这种行为?我使用 history.pushState(null, null, '#test'); 推送历史状态。然后,当尝试使用console.log(window.location.ha
这里是相关代码: https://www.facebook.com/sharer/sharer.php?u={{$location.absUrl()}} https://www.facebook.c
这两个重定向之间有什么区别?我有一个应用程序,当我使用时,它可以在 chrome 和 android 4 上正常工作,但在 android 2.x.x 上不能正常工作 document.locatio
JavaScript 的区别是什么 window.location.href = window.location.href 和 window.location.reload() 功能? 最佳答案 如果
有什么区别 window.location.href="http://example.com"; window.location.replace("http://example.com"); wind
JavaScript 的区别是什么 window.location.href = window.location.href 和 window.location.reload() 功能? 最佳答案 如果
以下 3 个指令之间有区别吗? location ~* \.(png)$ { expires max; log_not_found off; } location ~ \.(png)$ {
位于正文末尾之前的以下脚本在 Internet Explorer 和 Chrome(以及任何其他浏览器)中都会被调用。但重定向到指定的 URL 仅发生在 IE 中。我还尝试了 window.locat
我正在使用 Angular ngRouter。我需要更改 url 路径以及搜索参数。我知道 $location.path 和 $location.search,但是有没有一个函数可以同时设置它们? 最
在angularjs中用$location和window.location哪个更好。 例如,我们可以使用$location.path() 或window.location.href 来完成同样的工作。
我在我的网站上使用上述 2 个命令。似乎它们对 95% 访问它应该触发的页面的人有效,但对其他人则不会。 有谁知道是否可以完全阻止这些 javascript 命令?我真的很头疼为什么它们有时不起作用。
这是我无法弄清楚的另一个错误。 我有这个类ExtendedLocation extends Location实例化时抛出 ClassCastExceptioncurrentGpsLocation =
我一直在尝试简单地将一个包含两个变量(一个字符串和一个位置)的类推送和读取到 firebase,但我一直收到此错误。 **com.google.firebase.database.DatabaseEx
我注意到 iPhone 上的“常用位置”似乎比监控 iOS 访问的应用程序 (https://developer.apple.com/reference/corelocation/clvisit) 使
在我的 javascript 代码中,在某些时候,我需要刷新窗口(用户上传了新图片但在页面中仍然可以看到它) 我想知道为什么 location.href = location.href 不刷新窗口?
我是一名优秀的程序员,十分优秀!