小编law*_*law的帖子

Android Activity 正在重新启动

我正在制作一个应用程序,其中的一项功能是每 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)

java lifecycle android google-api-client android-activity

5
推荐指数
1
解决办法
4414
查看次数

尽管它是superClass android.support.v4.app.ActivityCompat下的抽象方法,但未能覆盖onRequestPermissionsResult函数

正如标题所示,我试图覆盖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)

java inheritance android superclass android-gradle-plugin

2
推荐指数
1
解决办法
2652
查看次数