我需要获取安装了我的应用程序的Android设备的硬件序列代码.您可以看到此硬件序列号Settings > About Device > Status > Serial number
.
我虽然可以使用它Settings.Secure.ANDROID_ID or android.os.Build.SERIAL
,但它们都没有用,这意味着它们没有给我我想要的唯一标识符.例如android.os.Build.SERIAL
,当您运行命令adb devices时,获取ADB上显示的唯一ID .
请注意,这个问题的目标不是找到可以帮助我的另一个唯一标识符,而只是获取设备硬件序列号.
谢谢您的帮助.
编辑:
请注意,我不是在寻找字符串android.os.BUILD.SERIAL提供的值.我知道如何获得这个价值,但我对此并不感兴趣.
我有三星设备,因此,他们使用的序列号与android.os.BUILD.SERIAL提供的序列号不同.
我有一个 Android 应用程序,它扩展了Application
该类,并且有许多应用程序组件(服务、活动和广播接收器)在三个不同的进程中运行。
每个进程将在Application
启动后立即实例化该类。所以我一直在寻找如何检查Application
类代码,如果实例归主应用程序进程所有,但我找不到任何东西。
我的清单看起来像这样:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".MyApplication"
android:theme="@style/AppTheme" >
<activity
android:name="...">
...
</activity>
<activity
android:name="...">
...
</activity>
<service android:name="..." >
</service>
<service android:name="..."
android:process=":SecondProcess" >
</service>
<service android:name="..."
android:process=":ThirdProcess" >
</service>
Run Code Online (Sandbox Code Playgroud)
接下来是我的Application
类实现:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (is this instance being ran on the main process?) {
// Do something
}
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何检查实例是否在主进程上运行?
我有一个git存储库,其文件的行结尾应该是签出的CRLF或LR,具体取决于具体的文件.例如,我希望所有*.sh文件都使用LR行结尾检出,而所有*.bat文件都使用CRLF.
我一直想把它拉下来没有结果,接下来是我的.gitattributes
档案:
* text=auto
#
# Declare files that will always have CRLF line endings on checkout.
#
*.sh text eol=LF
#
# Declare files that will always have LF line endings on checkout.
#
*.bat text eol=CRLF
#
# Denote all files that are truly binary and should not be modified.
#
*.zip binary
*.tar binary
*.exe binary
*.dll binary
*/dropbear binary
*update-binary binary
Run Code Online (Sandbox Code Playgroud)
当我打开.sh
文件或.bat
文件时,两个行结尾都是CRLF.我究竟做错了什么?
注意:我在Windows计算机上开发.
编辑:系统,全局和本地配置
系统:
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto …
Run Code Online (Sandbox Code Playgroud) 我有以下内容:
class User(models.Model)
blablabla
class Product(models.Model)
authorized_users = models.ManyToManyField(
User,
related_name='shared_products',
)
Run Code Online (Sandbox Code Playgroud)
我已经将 的 管理员配置为Product
显示authorized_users
为水平过滤器,以便选择可以编辑产品的所有用户。
class ProductAdmin(admin.ModelAdmin):
filter_horizontal = (
'authorized_users',
)
admin.site.register(Product, ProductAdmin)
Run Code Online (Sandbox Code Playgroud)
问题是我想在 的 管理中执行相同的操作User
,这意味着我想要 的 水平过滤器shared_products
,以便选择该用户能够编辑的产品。我已经尝试过以下显然不起作用的方法:
class UserAdmin(admin.ModelAdmin):
filter_horizontal = (
'authorized_users',
)
admin.site.register(User, UserAdmin)
Run Code Online (Sandbox Code Playgroud)
我发现的其他答案推荐使用内联,但正如我所见,它们用于编辑另一端的模型实例,这不是我想要做的。
有人知道如何实现这一目标吗?
android ×2
django ×1
django-admin ×1
git ×1
java ×1
java-threads ×1
lf ×1
line-endings ×1
many-to-many ×1
multiprocess ×1
newline ×1
settings ×1