當前位置:首頁 » 安卓系統 » android獲取包名

android獲取包名

發布時間: 2022-01-11 13:55:19

❶ 如何在androidmanifest獲取應用包名

我在程序中安裝其他的apk應用,之後我想知道我安裝的apk應用的包名,以及入口activity的名。。。。。

❷ 如何獲得Android系統自帶的應用程序的包名

下載一個叫「Link2sd」的應用程序,安裝後即可看到手機內應用的包名了,望能採納謝謝!

❸ android安裝的時候獲取包名

一般這種信息都是放在清單文件中的meta-data標簽中吧
<meta-data
android:name="名字"
android:value="推廣碼" />
context.getApplicationInfo().metaData.getXXX("名字");

❹ 關於Android APP包名CMD查看

/前面的為包名,後面的是該APP中的某個功能的快捷名。

❺ 如何獲取安卓程序包名

用RE管理器進入
|data|app
(那個|是反斜杠的意思)
這樣就能看到應用的包名了,最後帶的-1.apk不算。

❻ android開發怎麼獲取包名

PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
info.packageName就是包名

❼ Android獲取所有正在運行程序的包名

獲得應用程序信息的的方法如下:

public abstract ApplicationInfo getApplicationInfo(String packageName, int flags)
參數:packagename 包名
flags 該ApplicationInfo是此flags標記,通常可以直接賦予常數0即可
功能:返回ApplicationInfo對象

❽ Android怎麼獲取一個包下的全部類名

您好,我在別的論壇也看到您的問題,很高興為您解答:

/**
* 從包package中獲取所有的Class
*
* @param pack
* @return
*/
public static Set<Class<?>> getClasses(Package pack) {

// 第一個class類的集合
Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
// 是否循環迭代
boolean recursive = true;
// 獲取包的名字 並進行替換
String packageName = pack.getName();
String packageDirName = packageName.replace('.', '/');
// 定義一個枚舉的集合 並進行循環來處理這個目錄下的things
Enumeration<URL> dirs;
try {
dirs = Thread.currentThread().getContextClassLoader().getResources(
packageDirName);
// 循環迭代下去
while (dirs.hasMoreElements()) {
// 獲取下一個元素
URL url = dirs.nextElement();
// 得到協議的名稱
String protocol = url.getProtocol();
// 如果是以文件的形式保存在伺服器上
if ("file".equals(protocol)) {
// 獲取包的物理路徑
String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
// 以文件的方式掃描整個包下的文件 並添加到集合中
(packageName, filePath,
recursive, classes);
} else if ("jar".equals(protocol)) {
// 如果是jar包文件
// 定義一個JarFile
JarFile jar;
try {
// 獲取jar
jar = ((JarURLConnection) url.openConnection())
.getJarFile();
// 從此jar包 得到一個枚舉類
Enumeration<JarEntry> entries = jar.entries();
// 同樣的進行循環迭代
while (entries.hasMoreElements()) {
// 獲取jar里的一個實體 可以是目錄 和一些jar包里的其他文件 如META-INF等文件
JarEntry entry = entries.nextElement();
String name = entry.getName();
// 如果是以/開頭的
if (name.charAt(0) == '/') {
// 獲取後面的字元串
name = name.substring(1);
}
// 如果前半部分和定義的包名相同
if (name.startsWith(packageDirName)) {
int idx = name.lastIndexOf('/');
// 如果以"/"結尾 是一個包
if (idx != -1) {
// 獲取包名 把"/"替換成"."
packageName = name.substring(0, idx)
.replace('/', '.');
}
// 如果可以迭代下去 並且是一個包
if ((idx != -1) || recursive) {
// 如果是一個.class文件 而且不是目錄
if (name.endsWith(".class")
&& !entry.isDirectory()) {
// 去掉後面的".class" 獲取真正的類名
String className = name.substring(
packageName.length() + 1, name
.length() - 6);
try {
// 添加到classes
classes.add(Class
.forName(packageName + '.'
+ className));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (IOException e) {
e.printStackTrace();
}

return classes; }
/**
* 以文件的形式來獲取包下的所有Class
*
* @param packageName
* @param packagePath
* @param recursive
* @param classes
*/
public static void (String packageName,
String packagePath, final boolean recursive, Set<Class<?>> classes) {
// 獲取此包的目錄 建立一個File
File dir = new File(packagePath);
// 如果不存在或者 也不是目錄就直接返回
if (!dir.exists() || !dir.isDirectory()) {
return;
}
// 如果存在 就獲取包下的所有文件 包括目錄
File[] dirfiles = dir.listFiles(new FileFilter() {
// 自定義過濾規則 如果可以循環(包含子目錄) 或則是以.class結尾的文件(編譯好的java類文件)
public boolean accept(File file) {
return (recursive && file.isDirectory())
|| (file.getName().endsWith(".class"));
}
});
// 循環所有文件
for (File file : dirfiles) {
// 如果是目錄 則繼續掃描
if (file.isDirectory()) {
(packageName + "."
+ file.getName(), file.getAbsolutePath(), recursive,
classes);
} else {
// 如果是java類文件 去掉後面的.class 只留下類名
String className = file.getName().substring(0,
file.getName().length() - 6);
try {
// 添加到集合中去
classes.add(Class.forName(packageName + '.' + className));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
}
轉載,僅供參考。
如果我的回答沒能幫助您,請繼續追問。

❾ android applicationinfo類中怎麼獲取包名



public static int getVerCode(Context context) {
int verCode = -1;
try {
verCode = context.getPackageManager().getPackageInfo(
"包名", 0).versionCode;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verCode;
}

public static String getVerName(Context context) {
String verName = "";
try {
verName = context.getPackageManager().getPackageInfo(
"包名", 0).versionName;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verName;
}

❿ 請問如何獲取安卓正在前台運行的應用程序的包名

在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="android.permission.RESTART_PACKAGES" /> 主要是前面的am.killBackgroundProcesses(packageName);方法要這個許可權。

熱點內容
上傳文件文件夾找不到 發布:2024-09-20 00:26:32 瀏覽:914
承台箍筋加密區 發布:2024-09-20 00:26:31 瀏覽:227
筆記本什麼配置能流暢運行cf 發布:2024-09-20 00:14:19 瀏覽:951
實測華為編譯器 發布:2024-09-19 23:50:52 瀏覽:821
linux匯總 發布:2024-09-19 23:46:39 瀏覽:452
阿里雲伺服器環境搭建教程 發布:2024-09-19 23:21:58 瀏覽:837
黃色文件夾圖標 發布:2024-09-19 23:19:22 瀏覽:684
mysql資料庫導出導入 發布:2024-09-19 23:00:47 瀏覽:183
lua腳本精靈 發布:2024-09-19 23:00:41 瀏覽:659
任務欄文件夾圖標 發布:2024-09-19 22:54:25 瀏覽:101