如何sql获取所有表名称手机上所有运行APP的名称或者Buildle ID

4870人阅读
Class c =NSClassFromString(@&LSApplicationWorkspace&);
& &id s = [(id)cperformSelector:NSSelectorFromString(@&defaultWorkspace&)];
& &NSArray *array = [s
performSelector:NSSelectorFromString(@&allInstalledApplications&)];
& &for (id itemin array) {
& & & &NSLog(@&%@&,[itemperformSelector:NSSelectorFromString(@&applicationIdentifier&)]);
& & & &NSLog(@&%@&,[itemperformSelector:NSSelectorFromString(@&bundleIdentifier&)]);
& & & &NSLog(@&%@&,[itemperformSelector:NSSelectorFromString(@&bundleVersion&)]);
& & & &NSLog(@&%@&,[itemperformSelector:NSSelectorFromString(@&shortVersionString&)]);
这些全是私有的API,会有审核被拒的风险,谨慎使用
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:475418次
积分:7011
积分:7011
排名:第3289名
原创:123篇
评论:109条
文章:11篇
阅读:38247
(9)(3)(5)(7)(7)(21)(6)(16)(8)(27)(9)(2)(11)(6)(3)1785人阅读
Android(67)
启动程序,获取程序信息:
代码如下:
创建一个AppInfo类来表示应用程序
&pre name=&code& class=&java&&public class AppInfo {
public CharS// 程序名
public CharSequence packageN // 程序包名
I// 启动Intent
public D// 程序图标
* 设置启动该程序的Intent
final void setActivity(ComponentName className, int launchFlags) {
intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(className);
intent.setFlags(launchFlags);
创建程序列表的适配器:
* 程序列表适配器
* @author bill
public class ShowAppListAdapter extends BaseAdapter {
private ArrayList&AppInfo& appL
private LayoutI
public ShowAppListAdapter(Context context,ArrayList&AppInfo& appList,
PackageManager pm) {
this.appList = appL
inflater = LayoutInflater.from(context);
public int getCount() {
return appList.size();
public Object getItem(int position) {
return appList.get(position);
public long getItemId(int position) {
public View getView(int position, View convertView, ViewGroup parent) {
final AppInfo info = appList.get(position);
ViewHolder holder =
if(null == convertView){
convertView = inflater.inflate(R.layout.app_list_item, null);
holder = new ViewHolder();
holder.lv_image = (ImageView) convertView.findViewById(R.id.lv_icon);
holder.lv_name = (TextView) convertView.findViewById(R.id.lv_item_appname);
holder.lv_packname = (TextView) convertView.findViewById(R.id.lv_item_packageame);
convertView.setTag(holder);
holder = (ViewHolder) convertView.getTag();
holder.lv_image.setImageDrawable(info.icon);
final CharSequence name = info.
final CharSequence packName = info.packageN
holder.lv_name.setText(name);
holder.lv_packname.setText(packName);
return convertV
private final static
class ViewHolder{
ImageView lv_
TextView lv_
TextView lv_
public class MainActivity extends Activity {
* 应用程序集合
private ArrayList&AppInfo& appI
private ListView lv_
* 管理应用程序包,并通过它获取程序信息
private PackageM
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app_list);
pm = getPackageManager();
initView();
new Thread(runable).start();
private void initView(){
lv_app = (ListView) findViewById(R.id.app_list_view);
lv_app.setOnItemClickListener(new AppDetailLinster());
private final Runnable runable = new Runnable() {
public void run() {
loadApplications();
myHandler.obtainMessage().sendToTarget();
private Handler myHandler = new Handler() {
public void handleMessage(Message msg) {
lv_app.setAdapter(new ShowAppListAdapter(MainActivity.this,
appInfos, pm));
* 加载应用列表
private void loadApplications() {
PackageManager manager = this.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List&ResolveInfo& apps = manager.queryIntentActivities(
mainIntent, 0);
Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager));
if (apps != null) {
final int count = apps.size();
if (appInfos == null) {
appInfos = new ArrayList&AppInfo&(count);
appInfos.clear();
for (int i = 0; i & i++) {
AppInfo application = new AppInfo();
ResolveInfo info = apps.get(i);
application.title = info.loadLabel(manager);
application.setActivity(new ComponentName(
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
application.icon = info.activityInfo.loadIcon(manager);
application.packageName = info.activityInfo.applicationInfo.packageN
appInfos.add(application);
* 列表监听类
* @author bill
public final class AppDetailLinster implements OnItemClickListener {
public void onItemClick(AdapterView&?& view, View arg1,
final int position, long arg3) {
AlertDialog.Builder builder = new AlertDialog.Builder(
MainActivity.this);
builder.setTitle(&选项&);
builder.setItems(R.array.choice, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final AppInfo appInfo = appInfos.get(position);
switch (which) {
case 0: // 启动程序
startApp(appInfo);
} catch (Exception e) {
case 1: // 详细信息
showAppDetail(appInfo);
} catch (Exception e) {
dialog.dismiss();
private void showAppDetail(AppInfo appInfo)
throws Exception {
final String packName = appInfo.packageName.toString();
final PackageInfo packInfo = getAppPackinfo(packName);
final String versionName = packInfo.versionN
final String[] apppremissions = packInfo.requestedP
final String appName = appInfo.title.toString();
Intent showDetailIntent = new Intent(MainActivity.this,
ShowAppDetailActivity.class);
Bundle bundle = new Bundle();
bundle.putString(&packagename&, packName);
bundle.putString(&appversion&, versionName);
bundle.putStringArray(&apppremissions&, apppremissions);
bundle.putString(&appname&, appName);
showDetailIntent.putExtras(bundle);
startActivity(showDetailIntent);
private void startApp(AppInfo appInfo)
throws Exception {
final String packName = appInfo.packageName.toString();
final String activityName = getActivityName(packName);
if (null == activityName) {
Toast.makeText(MainActivity.this, &程序无法启动&,
Toast.LENGTH_SHORT);
Intent intent = new Intent();
intent.setComponent(new ComponentName(packName,
activityName));
startActivity(intent);
dialog = builder.create();
dialog.show();
* 获取程序信息
* @param packName
* @throws Exception
public PackageInfo getAppPackinfo(String packName) throws Exception {
return pm.getPackageInfo(packName, PackageManager.GET_ACTIVITIES
| PackageManager.GET_PERMISSIONS);
* 获取启动相关程序的Activity
* @param packName
* @throws Exception
public String getActivityName(String packName) throws Exception {
final PackageInfo packInfo = pm.getPackageInfo(packName,
PackageManager.GET_ACTIVITIES);
final ActivityInfo[] activitys = packInfo.
if (null == activitys || activitys.length &= 0) {
return activitys[0].
app_list.xml:
&?xml version=&1.0& encoding=&utf-8&?&
&RelativeLayout xmlns:android=&/apk/res/android&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&
android:orientation=&vertical&
android:background=&@android:color/black& &
android:id=&@+id/app_list_view&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&
&/ListView&
&/RelativeLayout&
app_list_item.xml:
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout xmlns:android=&/apk/res/android&
android:orientation=&horizontal& android:layout_width=&fill_parent&
android:layout_height=&wrap_content& android:gravity=&center_vertical&&
&ImageView
android:id=&@+id/lv_icon&
android:layout_width=&48px&
android:layout_height=&48px&
android:layout_marginTop=&5px&
android:layout_marginBottom=&5px&
&&/ImageView&
&LinearLayout
android:orientation=&vertical&
android:layout_width=&wrap_content&
android:layout_height=&48px&
android:paddingLeft=&5px&
android:id=&@+id/lv_item_appname&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:singleLine=&true&
android:textSize=&16px&
android:textStyle=&bold&
android:textColor=&#fff&
&&/TextView&
android:id=&@+id/lv_item_packageame&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:singleLine=&true&
android:textColor=&#fff&
&&/TextView&
&/LinearLayout&
&/LinearLayout&
* 查看应用信息
* @author bill
public class ShowAppDetailActivity extends Activity {
private TextView tv_
private TextView tv_
private TextView tv_
private TextView tv_
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.app_detial);
tv_appname = (TextView) findViewById(R.id.detail_app_name);
tv_appversion = (TextView) findViewById(R.id.detail_app_version);
tv_packagename = (TextView) findViewById(R.id.detail_app_packname);
tv_permission = (TextView) findViewById(R.id.detail_app_permissions);
Bundle bundle = this.getIntent().getExtras();
String packagename=
bundle.getString(&packagename&);
String appversion = bundle.getString(&appversion&);
String appname = bundle.getString(&appname&);
String[] appPremissions = bundle.getStringArray(&apppremissions&);
StringBuilder sb = new StringBuilder();
for(String s : appPremissions){
sb.append(s);
sb.append(&\n&);
tv_appname.setText(appname);
tv_appversion.setText(appversion);
tv_packagename.setText(packagename);
tv_permission.setText(sb.toString());
app_detial.xml:
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout xmlns:android=&/apk/res/android&
android:orientation=&vertical&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&
&TableLayout
android:id=&@+id/app_table&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&&
android:id=&@+id/tableRow1&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&程序名字&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:id=&@+id/detail_app_name&
&/TableRow&
android:id=&@+id/tableRow2&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&程序版本&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:id=&@+id/detail_app_version&
&/TableRow&
android:id=&@+id/tableRow3&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&程序包名&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:id=&@+id/detail_app_packname&
&/TableRow&
android:id=&@+id/tableRow4&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&程序权限&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:id=&@+id/detail_app_permissions&
&/TableRow&
&/TableLayout&
&/LinearLayout&
最后别忘了配置AndroidManifest。
转载请注明出处:情绪控_
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:401774次
积分:6924
积分:6924
排名:第3350名
原创:201篇
译文:24篇
评论:118条
做从未做的事,叫成长;做不愿做的事,叫改变;做不敢做的事,叫突破。在学习中成长,在正向里改变,在尝试时突破,给人生一次变好的机会。生命,要用智慧驾驭,用从容相随,用简单诠释,用自由概括,用快乐装饰,用希望照耀,用成功证明,用心灵体验,或许凡俗但真实,或许平庸但挚诚。
文章:15篇
阅读:44873
文章:38篇
阅读:36760
文章:74篇
阅读:150470
文章:18篇
阅读:29646
阅读:9160涓婚? : 濡備綍鑾峰彇鎵嬫満涓婃墍鏈夎繍琛孉PP鐨勫悕绉版垨鑰匓uildle ID
绾у埆: 渚犲?
UID: 534292
鍙戝笘: 85
鍙?彲璞

我要回帖

更多关于 mysql获取所有表名称 的文章

 

随机推荐