Android “的功能是什么?”;意图.行动“启动前”已完成;?
我想知道Intent.ACTION\u PRE\u BOOT\u COMPLETED的确切功能。目前,我的要求是在设备引导完成之前完成任务,即在调用Android “的功能是什么?”;意图.行动“启动前”已完成;?,android,android-intent,Android,Android Intent,我想知道Intent.ACTION\u PRE\u BOOT\u COMPLETED的确切功能。目前,我的要求是在设备引导完成之前完成任务,即在调用Intent.ACTION\u BOOT\u COMPLETED之前。 有人能指导我如何继续满足要求吗?在这方面的任何帮助都将不胜感激 没有像操作预启动完成这样的操作。我认为你通常不能满足你的要求。系统签名的应用程序可能有某种机制来完成此操作。操作预启动完成后将在ActivityManagerService.java::systemReady中发送
Intent.ACTION\u BOOT\u COMPLETED
之前。
有人能指导我如何继续满足要求吗?在这方面的任何帮助都将不胜感激 没有像操作预启动完成这样的操作。我认为你通常不能满足你的要求。系统签名的应用程序可能有某种机制来完成此操作。操作预启动完成后将在ActivityManagerService.java::systemReady中发送 但要接收它,应用程序的uid必须是system(1000) 此外,每次升级只能接收一次此广播(此处不是很确定,可能应该是每次擦除数据) 注意下面的代码,如果目标位于lastDoneReceivers中,它将被删除
ArrayList<ComponentName> lastDoneReceivers = readLastDonePreBootReceivers();
final ArrayList<ComponentName> doneReceivers = new ArrayList<ComponentName>();
for (int i=0; i<ris.size(); i++) {
ActivityInfo ai = ris.get(i).activityInfo;
ComponentName comp = new ComponentName(ai.packageName, ai.name);
if (lastDoneReceivers.contains(comp)) {
ris.remove(i);
i--;
}
}
ArrayList lastDoneReceivers=readlastdoneprebotroreceivers();
最终ArrayList doneReceivers=新ArrayList();
对于(int i=0;i 0){
num--;
字符串pkg=dis.readUTF();
字符串cls=dis.readUTF();
添加(新组件名(pkg,cls));
}
}
}
}catch(filenotfounde异常){
}捕获(IOE异常){
Slog.w(标签“故障读取上次完成的引导前接收器”,e);
}最后{
如果(fis!=null){
试一试{
fis.close();
}捕获(IOE异常){
}
}
}
返回最近的接收器;
}
以下是关于android开发者的交叉帖子和讨论:嗨,弗拉基米尔·伊万诺夫,谢谢你的回复。目前,我的任务是在设备引导完成之前在定制的锁屏上显示一些动画。可能吗?或者我必须只在设备启动后显示动画。目前,我正在处理ICS source.ActivityManagerService.java public void systemReady(final Runnable goingCallback){已同步(this){if(mSystemReady){if(goingCallback!=null)goingCallback.run();return;}//检查是否有任何更新接收器要运行。如果(!mDidUpdate){if(mWaitingUpdate){return;}Intent Intent Intent=new Intent(Intent.ACTION_PRE_BOOT_COMPLETED);List ris=null;请重试{
ArrayList<ComponentName> lastDoneReceivers = readLastDonePreBootReceivers();
final ArrayList<ComponentName> doneReceivers = new ArrayList<ComponentName>();
for (int i=0; i<ris.size(); i++) {
ActivityInfo ai = ris.get(i).activityInfo;
ComponentName comp = new ComponentName(ai.packageName, ai.name);
if (lastDoneReceivers.contains(comp)) {
ris.remove(i);
i--;
}
}
private static File getCalledPreBootReceiversFile() {
File dataDir = Environment.getDataDirectory();
File systemDir = new File(dataDir, "system");
File fname = new File(systemDir, "called_pre_boots.dat");
return fname;
}
static final int LAST_DONE_VERSION = 10000;
private static ArrayList<ComponentName> readLastDonePreBootReceivers() {
ArrayList<ComponentName> lastDoneReceivers = new ArrayList<ComponentName>();
File file = getCalledPreBootReceiversFile();
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
DataInputStream dis = new DataInputStream(new BufferedInputStream(fis, 2048));
int fvers = dis.readInt();
if (fvers == LAST_DONE_VERSION) {
String vers = dis.readUTF();
String codename = dis.readUTF();
String build = dis.readUTF();
if (android.os.Build.VERSION.RELEASE.equals(vers)
&& android.os.Build.VERSION.CODENAME.equals(codename)
&& android.os.Build.VERSION.INCREMENTAL.equals(build)) {
int num = dis.readInt();
while (num > 0) {
num--;
String pkg = dis.readUTF();
String cls = dis.readUTF();
lastDoneReceivers.add(new ComponentName(pkg, cls));
}
}
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
Slog.w(TAG, "Failure reading last done pre-boot receivers", e);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
}
}
}
return lastDoneReceivers;
}