gpt4 book ai didi

android - 使用 Fused Location API 检索位置时无法处理 android.intent.package_ADDED 和 REMOVED 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:38:46 25 4
gpt4 key购买 nike

我正在创建实现 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com