【发布时间】:2014-08-29 10:45:14
【问题描述】:
我的项目确实有很大的问题。当我的手机通过 USB 数据线连接到计算机时,一切正常,但是当手机断开连接时,应用程序无法按预期工作。所以,我已经尝试过android.os.Debug.waitForDebugger(),我删除了所有@SuppressLint("NewApi"),我的手机上也激活了USB调试器,但我认为问题可能出在Manifest文件中。谁能告诉我,在这种情况下可以做什么?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/fritz_logo"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity
android:windowSoftInputMode="adjustPan"
android:name="com.example.androproject.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.androproject.RegisterDnsAndUser"
android:screenOrientation="portrait"
android:theme="@style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation"/>
<activity
android:name="com.example.androproject.MenuApp"
android:screenOrientation="portrait"
android:theme="@style/ThemeWithCorners"
android:configChanges="keyboardHidden|orientation"/>
</application>
</manifest>
我正在使用以下处理程序代码。当我输入 40000 毫秒时,应用程序可以工作,但是当我输入 60000 毫秒时,如果电缆断开,我的应用程序将无法工作。
handler.postDelayed(myRunnable = new Runnable(){
@Override
public void run() {
if(btnToggle.isChecked()){
btnToggle.setChecked(false);
btnToggleTimer.setChecked(false);
}else{
btnToggle.setChecked(true);
btnToggleTimer.setChecked(false);
}
}
}, min*60000);
【问题讨论】:
-
您能否提供有关“应用程序无法按预期运行”的更多详细信息?你到底看到了什么不同?
-
avd 和 device 的 api 级别是否相同?我们需要更多细节!
-
是的,我已经编辑了更多细节,是的,它们是相同的 api 级别。