0
点赞
收藏
分享

微信扫一扫

Android PackageInstaller:安装应用的应用,android综合面试

我是芄兰 2022-02-05 阅读 146

mAppInfo = null;

}

} catch (NameNotFoundException e) {

mAppInfo = null;

}

mInstallFlowAnalytics.setReplace(mAppInfo != null);

mInstallFlowAnalytics.setSystemApp(

(mAppInfo != null) && ((mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0));

startInstallConfirm();

}else{

finish();

}

}

以上代码的效果就是,只安装包名以“com.zms”开头的应用。其他的不会出现安装界面,直接finish()。

2.PackageInstaller安装完某个应用,自动打开:

packages/apps/PackageInstaller/src/com/android/packageinstaller/InstallAppProgress.java

private Handler mHandler = new Handler() {

public void handleMessage(Message msg) {

switch (msg.what) {

case INSTALL_COMPLETE:

mInstallFlowAnalytics.setFlowFinishedWithPackageManagerResult(msg.arg1);

if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) {

Intent result = new Intent();

result.putExtra(Intent.EXTRA_INSTALL_RESULT, msg.arg1);

setResult(msg.arg1 == PackageManager.INSTALL_SUCCEEDED

? Activity.RESULT_OK : Activity.RESULT_FIRST_USER,

result);

finish();

return;

}

// Update the status text

mProgressBar.setVisibility(View.INVISIBLE);

// Show the ok button

int centerTextLabel;

int centerExplanationLabel = -1;

LevelListDrawable centerTextDrawable = (LevelListDrawable) getResources()

.getDrawable(R.drawable.ic_result_status);

if (msg.arg1 == PackageManager.INSTALL_SUCCEEDED) {

mLaunchButton.setVisibility(View.VISIBLE);

centerTextDrawable.setLevel(0);

centerTextLabel = R.string.install_done;

// Enable or disable launch button

mLaunchIntent = getPackageManager().getLaunchIntentForPackage(

mAppInfo.packageName);

boolean enabled = false;

if(mLaunchIntent != null) {

List list = getPackageManager().

queryIntentActivities(mLaunchIntent, 0);

if (list != null && list.size() > 0) {

enabled = true;

}

if (enabled) {

// ZMS:Add for opening app automatically START

if(mAppInfo.packageName.equals(“com.zms.demo”)){

startActivity(mLaunchIntent);

}

// ZMS:END

mLaunchButton.setOnClickListener(InstallAppProgress.this);

} else {

mLaunchButton.setEnabled(false);

}

} else if (msg.arg1 == PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE){

/// M: [ALPS00269830][ICS-TDD][Symbio][Free test] Assertion while playing music when downloading apks @{

if (!isFinishing()) {

Log.d(TAG, “!isFinishing()”); // Check to see whether this activity is in the process of finishing

showDialogInner(DLG_OUT_OF_SPACE);

}

/// @}

return;

} else {

// Generic error handling for all other error codes.

centerTextDrawable.setLevel(1);

centerExplanationLabel = getExplanationFromErrorCode(msg.arg1);

centerTextLabel = R.string.install_failed;

mLaunchButton.setVisibility(View.INVISIBLE);

}

if (centerTextDrawable != null) {

centerTextDrawable.setBounds(0, 0,

centerTextDrawable.getIntrinsicWidth(),

centerTextDrawable.getIntrinsicHeight());

mStatusTextView.setCompoundDrawablesRelative(centerTextDrawable, null,

null, null);

}

mStatusTextView.setText(centerTextLabel);

if (centerExplanationLabel != -1) {

mExplanationTextView.setText(centerExplanationLabel);

mExplanationTextView.setVisibility(View.VISIBLE);

最后

我见过很多技术leader在面试的时候,遇到处于迷茫期的大龄程序员,比面试官年龄都大。这些人有一些共同特征:可能工作了7、8年,还是每天重复给业务部门写代码,工作内容的重复性比较高,没有什么技术含量的工作。问到这些人的职业规划时,他们也没有太多想法。

其实30岁到40岁是一个人职业发展的黄金阶段,一定要在业务范围内的扩张,技术广度和深度提升上有自己的计划,才有助于在职业发展上有持续的发展路径,而不至于停滞不前。

不断奔跑,你就知道学习的意义所在!

以上进阶BATJ大厂学习资料可以免费分享给大家,需要完整版的朋友,【点这里可以看到全部内容】。

举报

相关推荐

0 条评论