我正在制作一个应用程序,其中的一项功能是每 10 秒更新一次用户位置。到目前为止,应用程序没有更新它的位置,因为在检索位置之前,活动已暂停并重新启动。我不明白为什么要重新启动活动。我最好的猜测是,由于没有很多事情发生,操作系统正在暂停活动,但是什么会触发活动重新启动?我之前尝试过构建应用程序,然后我从头开始,因为我犯了太多错误,但即使如此,我以前也没有遇到过这个问题。
D/selectRouteAndTransportMethod: On Start
D/myLocation: Connection Requested
D/selectRouteAndTransportMethod: Connecting
D/selectRouteAndTransportMethod: registered
D/myLocation: Connection Requested
V/FA: Activity resumed, time: 8562145
V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 32
V/FA: Activity paused, time: 8562177
V/FA: onActivityCreated
D/Activity: performCreate Call secproduct feature valuefalse
D/Activity: performCreate Call debug elastic valuetrue
D/selectRouteAndTransportMethod: On Start
D/myLocation: Connection Requested
D/selectRouteAndTransportMethod: Connecting
D/selectRouteAndTransportMethod: registered
D/myLocation: Connection Requested
V/FA: Activity resumed, time: 8562374
D/myLocation: OnConnected
D/myLocation: Permission Was Granted
V/FA: Screen exposed …
Run Code Online (Sandbox Code Playgroud) 正如标题所示,我试图覆盖onRequestPermissionsResult
抽象方法,但Gradle说该方法没有超类.
根据文档,超级类是ActivityCompat
我导入的.
我正在为基于位置的应用创建位置对象.
我该如何解决这个问题?
下面的代码片段
import android.*;
import android.Manifest;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.app.Activity;
import android.app.PendingIntent;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.Geofence;
import com.google.android.gms.location.GeofencingApi;
import com.google.android.gms.location.GeofencingRequest;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsResult;
import android.content.ContextWrapper;
import android.content.Context;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.content.ContextCompat;
import android.util.Log;
/**
* Created by User on 7/2/2016.
*/
public class GoogleLocationHandler implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener{
public GoogleApiClient mGoogleApiClient;
public …
Run Code Online (Sandbox Code Playgroud)