Java 我在 android 中的应用程序包名称是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21944464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 11:33:02  来源:igfitidea点击:

what's my application package name in android?

javaandroidmanifest

提问by Elad Benda

I'm writing an android application.

我正在编写一个android应用程序。

It has some packages under src.

它在src.

how can I figure out which of them is my application package?

我怎样才能找出其中哪一个是我的应用程序包?

I want to add C@DM permissions:

我想添加 C@DM 权限:

<permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" />

how will my YOUR_PACKAGE_NAMEchange if I create a custom MyApplication extends Applicationclass?

YOUR_PACKAGE_NAME如果我创建自定义MyApplication extends Application类,我将如何改变?

采纳答案by skoperst

Your application name is actually defined in the AndroidManifest.xml, in its first lines. Ex:

您的应用程序名称实际上是在 AndroidManifest.xml 的第一行中定义的。前任:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourcompany.appname"
    android:versionCode="66"
    android:versionName="0.57" >

note the package="com.yourcompany.appname" - this is your package definition.

注意 package="com.yourcompany.appname" - 这是你的包定义。

Other places which contain your package name can be resources, class paths, packages and much more. But all of them should be aligned according to the manifest because that what the package manager reads.

包含你的包名的其他地方可以是资源、类路径、包等等。但是所有这些都应该根据清单对齐,因为包管理器读取的内容。