
有一个相关adb 命令可以查看已安装应用的包名:
adb shell
su (需要获取系统管理员权限,也就是说手机必须root过才能执行下一步的命令)
ls -l /data/app
如图。至于版本号,图标这些东西在命令行是看不到的,都在应用内部打包了。
可以通过包名实现
Intent intent = getPackageManager()getLaunchIntentForPackage(packageName);
startActivity(intent);
Android开发过程中我们有时需要使用第三方apk资源,而启动第三方apk在某些情况下需要指定相应的包名和启动的Activity名,这个时候就需要获取这两个名称,我们可以使用如下三种方法:
1、使用aapt //aapt是sdk自带的一个工具,在你安装的Eclipse路径下的sdk\build-tools\中,如我的是D:\Eclipse\androidTools\sdk\build-tools\android-442,如果你下载有apk反编译工具,也可以直接使用里面的aapt
以“GO备份apk”为例,先进入cmd命令行窗口,然后运行:D: -> Eclipse\androidTools\sdk\build-tools\android-442
-> aapt dump badging C:\Users\Administrator\Desktop\GO备份apk,即可获取到AndroidManifestxml中我们需要的内容,如
package: name='comjiubanggobackupex'
launchable-activity: name='comjiubanggobackupproStartupPageActivity'
2、查看AndroidManifestxml
同样是查看AndroidManifestxml,这里我们可以采用反编译方法来获取信息,同样是打开cmd命令行窗口,然后运行:E:
-> apk反编译工具\apktool\apktool -> apktoolbat d -f C:\Users\Administrator\Desktop\GO备份apk GO备份,然后打开“GO备份”文件夹,打开droidManifestxml文件,找到manifest节点的package属性值package="comjiubanggobackupex"语句即为包名,查找androidintentactionMAIN和androidintentcategoryLAUNCHER对应的activity,该activity对应的android:name属性即为入口activity名称,如<activity
android:name="comjiubanggobackupproStartupPageActivity"。
3、使用uiautomatorviewer
可以直接在命令行输入uiautomatorviewer,打开获取屏幕截图工具,连接手机,打开所要获取包名的应用,然后获取其截图,根据截图查看package即可,uiautomatorviewer的使用这里就不做介绍了。使用这个需要注意的是,该app必须是有界面的,否则无法获取。
另外,
androidintentactionMAIN 属性决定应用程序最先启动的Activity
androidintentcategoryLAUNCHER属性决定应用程序是否显示在程序列表里
最近在做Android的平板的开发,想在桌面上预置一些第三方应用的Widget,在桌面预置Widget的方法就是要获得应用的包名和类名。桌面预置widget的方法 在Launcher的配置文件 res/xml/default_workspacexml中添加如下的代码:<appwidgetlauncher:packageName="comgoogleandroidappsgeniegeniewidget"//预置应用的包名launcher:className="comgoogleandroidappsgeniegeniewidgetminiwidgetMiniWidgetProvider"//预置应用的Provider的类名,不是Activity的类名launcher:screen="1"//在第几屏0为第一屏,launcher:x="0"//x坐标launcher:y="0"//y坐标launcher:spanX="4"//x方向占几个单元格launcher:spanY="1"///y方向占几个单元格通过logcat有时可以找到应用的包名和Provider类名,此方法不可取,容易出错。系统的widget可以通过查找相关的源码找到对应的包名和Provider的类名,但是第三方应用看不到源码,但是也可以通过反编译第三方应用,获得相应的Maifestxml文件,找到对应的包名和Provider类名,但是此方法比较繁琐。可以通过在Launcher中添加如下代码,可以将系统中所安装的所有 的widget的信息打印出来:在Launcherjava中的onCreate方法中添加下面的代码:List<AppWidgetProviderInfoproviders=mAppWidgetManagergetInstalledProviders();finalintproviderCount=providerssize();for(inti=0;i<providerCount;i++){ComponentNameprovider=providersget(i)provider;Logi("xxx","packagename:"+providergetPackageName()+"classname:"+providergetClassName());}新编译Launcher,把Launcher push进去之后,执行 adb logcat -s xxx,就可以看到打印出来的Log信息,包名和Provider了类名。桌面预置shortcut的方法:在Launcher的配置文件 res/xml/default_workspacexml中添加如下的代码:<favorites
用命令方获取:
Aapt dumpbadging xxxxapk
第一个框为包名
第二个框为主Activity名
如果取包名与Activity在命令行中不方例还可以用以下方式获取
Aapt dumpbadging xxxxapk >c:\apktxt
之后打开c:\apktxt!
在framework中想添加这个功能,所以写了个appliction来实现一下获取正在运行的应用程序: 还是先看图吧: 这个app主要是简单的实现了获取非系统的应用程序和一些常用的系统应用程序,显示在一个listview中,并添加了点击(回复到你打开的界面)和长按事件(关闭应用程序)。 看看代码吧: 直接贴出来再加上注释吧(直接写在一个文件里): package andorid/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="40dip" android:layout_height="40dip" /> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" /> <TextView android:id="@+id/info" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout> main: <xml version="1/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ListView android:id="@+id/list_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" ></ListView> </LinearLayout> 在manifest文件中要加以个权限: <uses-permission android:name="androidpermissionRESTART_PACKAGES" /> 主要是前面的amkillBackgroundProcesses(packageName);方法要这个权限。
以上就是关于linux怎么用命令看android手机上已安装应用的名字,包名,版本,图标。比如adb什么的。全部的内容,包括:linux怎么用命令看android手机上已安装应用的名字,包名,版本,图标。比如adb什么的。、android monkey runner中怎样获取应用程序的启动名、如何查看Android应用apk的包名和入口Activity名称等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)