private boolean isAirplaneModeOn(Context context) {
// 返回值是1时表示处于飞行模式
int modeIdx = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0);
boolean isEnabled = (modeIdx == 1);
//MyLog.v("[SleepReceiver]isAirplaneModeOn:" + isEnabled);
return isEnabled;
}
/**
*/
private void setAirplaneMode(boolean setAirPlane, Context context) { Settings.Global.putInt(context.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, setAirPlane ? 1 : 0);
// 广播飞行模式的改变,让相应的程序可以处理。
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra(“state”, setAirPlane);
context.sendBroadcast(intent);
}
public void killAppByPackageName(String package){
ActivityManager myActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List
for (ActivityManager.RunningAppProcessInfo amPro : mRunningPros){
if(amPro.processName.contains(package)){
try {
Method forceStopPackage = myActivityManager.getClass().getDeclaredMethod(“forceStopPackage”, String.class);
forceStopPackage.setAccessible(true);
forceStopPackage.invoke(myActivityManager, amPro.processName);
}
catch (Exception e) {
}
}
}
if (Constant.Module.muteWhenSleep) {
int volumeMusic = audioManager .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int volumeRing = audioManager .getStreamVolume(AudioManager.STREAM_RING);
editor.putInt(“volumeMusic”, volumeMusic);
editor.putInt(“volumeRing”, volumeRing);
editor.commit();
}
context.sendBroadcast(new Intent(
“tchip.intent.action.ACTION_GPS_OFF”));
private static boolean getGpsState(Context context) {
ContentResolver resolver = context.getContentResolver();
boolean gpsState = Settings.Secure.isLocationProviderEnabled(resolver,
LocationManager.GPS_PROVIDER);
Log.v(“ZMS”, “[GPS]Now State:” + gpsState);
return gpsState;
}
private void setGpsState(Context context, boolean isGpsOn) {
ContentResolver resolver = context.getContentResolver();
boolean nowState = getGpsState(context);
if (isGpsOn != nowState) {
Log.v(“ZMS”, “[GPS]Set State:” + isGpsOn);
Settings.Secure.setLocationProviderEnabled(resolver,
LocationManager.GPS_PROVIDER, isGpsOn);
}
}
private void releaseCameraZone() {
release();
// mHolder = null;
if (mCamera != null) {
mCamera.stopPreview();
}
MyApplication.shouldResetRecordWhenResume = true;
}
public void release() {
releaseRecorder();
closeCamera();
}
private void releaseRecorder() {
if (mMyRecorder != null) {
mMyRecorder.stop();
mMyRecorder.close();
mMyRecorder.release();
mMyRecorder = null;
MyLog.d(“Record Release”);
}
}
private boolean closeCamera() {
if (mCamera == null)
return true;
try {
mCamera.lock();
mCamera.stopPreview();
mCamera.setPreviewDisplay(null);
mCamera.release();
mCamera.unlock();
mCamera = null;
return true;
} catch (Exception ex) {
mCamera = null;
return false;
}
}
唤醒
–
if (!MyApplication.isFirstLaunch) {
if (!MyApplication.isVideoReording
|| MyApplication.shouldResetRecordWhenResume) {
MyApplication.shouldResetRecordWhenResume = false;
// 重置预览区域
if (mCamera == null) {
// mHolder = holder;
setup();
} else {
try {
mCamera.lock();
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
mCamera.unlock();
} catch (Exception e) {
// e.printStackTrace();
}
}
}
} else {
MyApplication.isFirstLaunch = false;
}
public void setup() {
开发是需要一定的基础的,我是08年开始进入Android这行的,在这期间经历了Android的鼎盛时期,和所谓的Android”凉了“。中间当然也有着,不可说的心酸,看着身边朋友,同事一个个转前端,换行业,其实当时我的心也有过犹豫,但是我还是坚持下来了,这次的疫情就是一个好的机会,大浪淘沙,优胜劣汰。再等等,说不定下一个黄金浪潮就被你等到了。
这是我在这行工作10几年积累的一些资料,如果还想继续在这行业走下去的,或者现在打算跳槽,可以**私信【学习】**我愿意把资料免费分享给大家。
或者直接点击下面链接领取
Android学习PDF+架构视频+面试文档+源码笔记
Android进阶系统学习视频
B%98%E8%96%AA%EF%BC%81.md)
330页 PDF Android核心笔记
[外链图片转存中…(img-VKjA1sKP-1646221049360)]
[外链图片转存中…(img-ohbiixc6-1646221049361)]
[外链图片转存中…(img-7pyDPypk-1646221049362)]
[外链图片转存中…(img-LglHct5O-1646221049363)]