我很想知道能否具体确定一个安乐器是否被装入计算机或公正的电力。
主要原因是,我用电话打上“Stay Awake”的电话,当它被拖入计算机,而我却正在开发,但不是当它被拖到一个夜里的电网。
我认为,如果我能够告诉我与我有什么关系的话,我可以利用行动——POWER_CONNECTED来开始服务并检查与Uw Im有关的内容。
我很想知道能否具体确定一个安乐器是否被装入计算机或公正的电力。
主要原因是,我用电话打上“Stay Awake”的电话,当它被拖入计算机,而我却正在开发,但不是当它被拖到一个夜里的电网。
我认为,如果我能够告诉我与我有什么关系的话,我可以利用行动——POWER_CONNECTED来开始服务并检查与Uw Im有关的内容。
我实际上找到了确切的方法,来选择是否将 screen锁定在ACC、USB,或者通过在。
申请许可:android.permission。 页: 1
Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn.isChecked() ?
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
AC:BatteryManager.BATTERY_PLUGGED_AC
关于USB:BatteryManager.BATTERY_PLUGGED_USB
For Either: (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
首先,需要登记接收器以听取<代码> 编号:<0> 电池组.BATTERY_PLUGGED_USB。 下面是:
BroadcastReceiver receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
if (plugged == BatteryManager.BATTERY_PLUGGED_USB) {
Toast.makeText(getApplicationContext(), "Connected to USB, Stay Awake", Toast.LENGTH_LONG).show();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "WakeLock");
wl.acquire();
}
}
};
// register the receiver to listen to battery change
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(receiver, filter);
您也需要得到您的安妮斯·汉内尔的许可,以便能够保持觉醒。
<uses-permission android:name="android.permission.WAKE_LOCK" />
One other note, at some point you will need to unregister the receiver. You could provide that via settings page to call unregisterReceiver
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...