activityManager是什么它具体有什么作用

activityManager是什么它具体有什么作用

本文目录

  • activityManager是什么它具体有什么作用
  • PackageManager和ActivityManager的区别是什么
  • android怎样判断应用程序退到后台
  • 如何初始化activitymanager
  • android系统activitymanager-launch是什么进程
  • android 怎么修改activitymanagerservice.java

activityManager是什么它具体有什么作用


这问题,一百度一大堆吧。。。讲的都很详细的。。。
http://blog.csdn.net/caowenbin/article/details/6036726
http://blog.sina.com.cn/s/blog_8984d3f301011peb.html

PackageManager和ActivityManager的区别是什么


  packagemanager是手机上所有安装软件的管理者,activitymanager是应用的activity的管理者,两者差的十万八千里吧,作用完全不同.

android怎样判断应用程序退到后台


/**
* 程序是否在前台运行
*
*/
public boolean isAppOnForeground() {
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
String packageName = getApplicationContext().getPackageName();
/**
* 获取Android设备中所有正在运行的App
*/
List《ActivityManager.RunningAppProcessInfo》 appProcesses = activityManager
.getRunningAppProcesses();
if (appProcesses == null)
return false;
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
// The name of the process that this object is associated with.
if (appProcess.processName.equals(packageName)
&& appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
return true;
}
}
return false;
}
这是我在网上找到的例子,主要的实现原理就是,使用ActivityManager,首先拿到自己App的包名,再拿到Android设备中所有正在运行的App包名,然后对所有的App进行遍历,通过判断正在运行的App中包名有没有和自己的App相等,从而判断自己的App是否退到后台.
@Override
protected void onPause() {
super.onPause();
if(!isAppOnForeground()){
Toast.makeText(getApplicationContext(), TAG+“onPause:“,
Toast.LENGTH_SHORT).show();
}else {
sendBroadcast(new Intent(NotificationIntentReceiver.ACTION_ENABLE_MESSAGES)
.setClass(this, NotificationIntentReceiver.class));
Toast.makeText(getApplicationContext(), TAG+“后台运行1“,
Toast.LENGTH_SHORT).show();
}
}
然后在onPause()方法中,进行判断,上面代码中实现的是,App退出后台就发送广播,然后在广播中执行Notification,然后在回到Activity时,在onResume()中清除应该清除Notification.

如何初始化activitymanager


在AndroidManifest.xml里修改 CdBusSearchActivity是主界面,如果想换成BusInfoActivity的话,只需交换两个的名字就行

android系统activitymanager-launch是什么进程


  通过ActivityManager我们可以获得系统里正在运行的activities,包括
  进程(Process)等、应用程序/包、服务(Service)、任务(Task)信息。
  

android 怎么修改activitymanagerservice.java


1 个文件发生了变化
android/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
android/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java查看文件 @a1b2236
@@ -889,6 +889,8 @@
return;
}
AppErrorResult res = (AppErrorResult) data.get(“result“);
+ res.set(0);
+ /*
if (!mSleeping && !mShuttingDown) {
Dialog d = new AppErrorDialog(mContext, res, proc);
d.show();
@@ -897,7 +899,7 @@
// The device is asleep, so just pretend that the user
// saw a crash dialog and hit “force quit“.
res.set(0);
- }
+ }*/
}

ensureBootCompleted();
@@ -3193,6 +3195,11 @@
return;
}

+ app.notResponding = false;
+ app.notRespondingReport = null;
+ app.anrDialog = null;
+
+ /*
// Set the app’s notResponding state, and look up the errorReportReceiver
makeAppNotRespondingLocked(app,
activity != null ? activity.shortComponentName : null,
@@ -3210,6 +3217,7 @@
}

mHandler.sendMessage(msg);
+ */
}
}

android/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java查看文件 @a1b2236
@@ -889,6 +889,8 @@
return;
}
AppErrorResult res = (AppErrorResult) data.get(“result“);
+ res.set(0);
+ /*
if (!mSleeping && !mShuttingDown) {
Dialog d = new AppErrorDialog(mContext, res, proc);
d.show();
@@ -897,7 +899,7 @@
// The device is asleep, so just pretend that the user
// saw a crash dialog and hit “force quit“.
res.set(0);
- }
+ }*/
}

ensureBootCompleted();
@@ -3193,6 +3195,11 @@
return;
}

+ app.notResponding = false;
+ app.notRespondingReport = null;
+ app.anrDialog = null;
+
+ /*
// Set the app’s notResponding state, and look up the errorReportReceiver
makeAppNotRespondingLocked(app,
activity != null ? activity.shortComponentName : null,
@@ -3210,6 +3217,7 @@
}

mHandler.sendMessage(msg);
+ */
}
}

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部