android获取已安装nolaunch(没有安装图标)的apk

本文介绍了一种方法,用于查询设备上已安装但没有设置为主启动器的应用(APK)。通过构造特定的Intent并使用PackageManager的queryIntentActivities方法,可以获取到这些应用的信息列表。
//获取已安装的apk为nolaunch的列表
    public static void isNoLaunchApp(Context context, String packageName) {
        List<ResolveInfo> apps;
        Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
        resolveIntent.addCategory(Intent.CATEGORY_DEFAULT);
        resolveIntent.setPackage(packageName);
        apps = context.getPackageManager().queryIntentActivities(resolveIntent, 0);

    }
status_t sstp_pppd_start(sstp_pppd_st *ctx, sstp_option_st *opts, const char *sockname) { status_t status = SSTP_FAIL; status_t ret = SSTP_FAIL; /* Launch PPPd, unless PPPd launched us */ if (!(SSTP_OPT_NOLAUNCH & opts->enable)) { const char *args[20]; int i = 0; int j = 0; /* Create the task */ ret = sstp_task_new(&ctx->task, SSTP_TASK_USEPTY); if (SSTP_OKAY != ret) { log_err("Could not create a new task for pppd"); goto done; } /* Configure the command line */ args[i++] = "/usr/sbin/pppd"; args[i++] = sstp_task_ttydev(ctx->task); args[i++] = "38400"; /* Write user to file */ if (opts->user) { args[i++] = "user"; args[i++] = opts->user; } /* Write the password to file */ if (opts->password) { int fd = 0; char buff[255]; sprintf(ctx->tmpfile, "%s/sstp-pppd.XXXXXX", SSTP_TMP_PATH); /* Create a file to keep the options */ fd = mkstemp(ctx->tmpfile); if (fd <= 0) { log_err("Could not create pppd script"); goto done; } /* Dump password to temporary file */ j = snprintf(buff, sizeof(buff), "password \"%s\"\n", opts->password); if (write(fd, buff, j) != j) { log_warn("Could not write password to file"); } /* Close file, and enable check for auth */ ctx->auth_check = 1; close(fd); /* Append the file argument to pppd */ args[i++] = "file"; args[i++] = ctx->tmpfile; /* Remember to delete the file */ ctx->del_file = 1; } /* In case we are using plugin */ if (!(opts->enable & SSTP_OPT_NOPLUGIN)) { args[i++] = "plugin"; args[i++] = "sstp-pppd-plugin.so"; args[i++] = "sstp-sock"; args[i++] = sockname; } /* Copy all the arguments to pppd */ for (j = 0; j < opts->pppdargc; j++) { args[i++] = opts->pppdargv[j]; } /* Terminate the argument vector */ args[i++] = NULL; /* Start the task */ ret = sstp_task_start(ctx->task, args); if (SSTP_OKAY != ret) { goto done; } /* Get the socket to listen on */ ctx->sock = sstp_task_stdout(ctx->task); /* Wait until pppd is configured and running before resuming recv() on SSTP stream */ status = SSTP_INPROG; } else { /* pppd is our parent, we communciate over a pty terminal */ ctx->sock = STDIN_FILENO; /* Success! */ status = SSTP_OKAY; } /* Need to record approximate time */ ctx->t_start = time(NULL); /* Add the event context */ ctx->ev_recv = event_new(ctx->ev_base, ctx->sock, EV_READ, (event_fn) sstp_pppd_recv, ctx); /* Add the receive event */ event_add(ctx->ev_recv, NULL); done: return status; }啥意思
最新发布
10-18
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值