相关疑难解决方法(0)

Android检查互联网连接

我想创建一个使用互联网的应用程序,我正在尝试创建一个检查连接是否可用的功能,如果不可用,请转到具有重试按钮和解释的活动.

附件是我的代码到目前为止,但我收到了错误 Syntax error, insert "}" to complete MethodBody.

现在我一直把这些放在试图让它工作,但到目前为止没有运气...任何帮助将不胜感激.

public class TheEvoStikLeagueActivity extends Activity {
    private final int SPLASH_DISPLAY_LENGHT = 3000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        private boolean checkInternetConnection() {
            ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
            // ARE WE CONNECTED TO THE NET
            if (conMgr.getActiveNetworkInfo() != null
                    && conMgr.getActiveNetworkInfo().isAvailable()
                    && conMgr.getActiveNetworkInfo().isConnected()) {

                return true;

                /* New Handler to start the Menu-Activity
                 * and close this Splash-Screen after …
Run Code Online (Sandbox Code Playgroud)

networking android android-networking

204
推荐指数
11
解决办法
31万
查看次数

打盹模式如何影响后台/前台服务,有/无部分/完整唤醒锁?

这是一个简单的问题,看到G +(这里)有关于此的大量帖子,以及官方文档(这里)缺乏信息:

当设备进入"打盹"模式时,应用程序的服务会发生什么变化?

它对后台/前台服务(绑定/未绑定,已启动/未启动)有什么作用,有/无部分/完整唤醒锁?

例如,为了创建在设备屏幕关闭时播放音频流的服务,您会做什么?如果音频流不是来自本地文件,而是来自网络,该怎么办?

看到Google开发者声称:

已经运行前台服务的应用程序(带有相关通知)不受打盹的限制.

- 之后进行了大量的讨论,声称这并不完全正确,我认为知道特殊的后台操作应用程序应该做什么是相当令人困惑的.

android android-service android-doze-and-standby android-doze

19
推荐指数
1
解决办法
5848
查看次数

地理围栏:通过后台服务发送时,HTTP请求失败.给出UnknownHostException

我在android应用程序中实现了Geofence.我按照这个链接在app中实现了'Geofence'.我正在使用'Retrofit'库来调用'HTTP'请求.


应用具有以下权限:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)


这是我的'IntentService'代码:

public class GeofenceService extends IntentService
{

    private static  final String TAG = GeofenceService.class.getName();


    public static final int GEOFENCE_NOTIFICATION_ID = 0;


    public GeofenceService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        // Retrieve the Geofencing intent
        GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);


        createLoggerFile();
        // Handling errors
        if ( geofencingEvent.hasError() ) {
            String errorMsg = getErrorString(geofencingEvent.getErrorCode() ); …
Run Code Online (Sandbox Code Playgroud)

java android http geofencing android-intentservice

15
推荐指数
2
解决办法
844
查看次数