小编Mil*_*nia的帖子

以授权的INSTALL_PACKAGES权限静默安装应用程序

我试图默默安装apk到系统中.我的应用程序位于/ system/app并成功授予权限"android.permission.INSTALL_PACKAGES"

但是我找不到任何地方如何使用此权限.我试图将文件复制到/ data/app并没有成功.我也试过使用这段代码

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(
            Uri.parse("file:///sdcard/app.apk"),
            "application/vnd.android.package-archive");
    startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

但是此代码打开标准安装对话框.如何在没有root的情况下以静默方式安装app android.permission.INSTALL_PACKAGES

PS我正在编写一个应用程序,它会在第一次启动时将许多来自文件夹的apks安装到系统中(替换安装向导).我需要它来使固件更轻.

如果您认为我正在编写病毒:所有程序都安装在/ data/app中.权限Install_packages只能授予位于/ system/app中的系统级程序或使用系统密钥签名.所以病毒无法到达那里.

如上所述http://www.mail-archive.com/android-porting@googlegroups.com/msg06281.html应用程序如果具有install_packages权限,则可以进行静默安装.此外,您不需要Install_packages权限来安装软件包.另外还有http://www.androidzoom.com/android_applications/tools/silent-installer_wgqi.html

android install silent

84
推荐指数
5
解决办法
12万
查看次数

Eclipse的Intelli +和Android Studio中的Ctrl + 1

我非常喜欢Eclipse中的Ctrl+ 1快捷方式(提示错误和迷你重构).在IntelliJ和Android Studio中是否有相同的功能?

eclipse intellij-idea android-studio

78
推荐指数
3
解决办法
2万
查看次数

简单的方法来做动态但方形的布局

我正在使用a GridView来显示一堆本质上的视图LinearLayouts.我希望LinearLayouts它们都是方形的,但我也希望它们是动态大小的 - 也就是说,有两列我希望LinearLayouts根据屏幕的大小进行拉伸但保持方形.有没有办法通过xml布局来做到这一点,还是我必须以编程方式设置高度和宽度?

android

78
推荐指数
6
解决办法
5万
查看次数

UICollectionView布局问题

我正在使用UICollectionView流程布局.我也为此做了一个习惯UICollectionViewCell.但是在运行项目时,控制台继续抛出这个错误 -

UICollectionView未定义的行为是因为:项目高度必须小于UICollectionViewCell减去该部分高度的顶部和底部值.

我确保细胞的大小是正确的

有没有人能够解决这个问题.提前致谢.

关心Nitesh

ios uicollectionview uicollectionviewlayout

61
推荐指数
5
解决办法
5万
查看次数

在android上使用全局异常处理

是否有代码示例或有关如何使用该Thread.setDefaultUncaughtExceptionHandler方法的教程?基本上我在我的应用程序中尝试在抛出异常时显示自定义警报对话框.是否有可能做到这一点?我知道在屏幕上显示某些内容有点棘手,如果在UI线程中抛出异常,但我不知道任何解决方法.

android exception-handling

58
推荐指数
4
解决办法
5万
查看次数

如何在android studio中移动(上/下)代码行?

在eclipse中,我们使用Alt+ / 来向上或向下移动线.

android studio中有任何快捷方式吗?或者任何快速避免复制和粘贴的方法?

ide intellij-idea android-studio

58
推荐指数
3
解决办法
2万
查看次数

在vim中显示尾随空格

我在.vimrc中设置了以下选项

set listchars=tab:?\ ,trail:·
set list
Run Code Online (Sandbox Code Playgroud)

并且期望在代码中使用空格用于制表的那些地方看点(我使用空格,而不是制表符).但结果却不同:

在此输入图像描述

您能否建议如何达到预期效果?谢谢!

vim indentation

42
推荐指数
4
解决办法
3万
查看次数

在BIOS安全设置中启用VT-x(请参阅计算机文档)

当我在Android Studio中添加虚拟设备时,Android Studio显示此错误.看这个图像: 在此输入图像描述 .

android android-studio haxm

32
推荐指数
3
解决办法
18万
查看次数

包含tag和dataBinding

我想在同一个视图中多次使用我的一个布局include.假设我有custom.xml一些包含TextViews.

custom.xml:

 <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我已将此布局多次包含在parent.xml:

 <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include layout="@layout/custom"
        android:id="@+id/layout1"/>

    <include layout="@layout/custom"
        android:id="@+id/layout2"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在我想将我的数据模型绑定到这个布局,但问题是我不知道如何绑定两个不同的数据模型layout1,layout2因为它们都是从一个布局中引用的custom.xml.据我所知,我可以在我的xml布局中添加此标记:

    <data>
       <variable name="user" type="com.myproject.model.User"/>
   </data>
Run Code Online (Sandbox Code Playgroud)

但我需要绑定两个不同的数据模型custom.xml.

我的问题是如何在一个视图中多次包含布局并使用数据绑定将不同的数据传递给它们?比如将数据传递给布局但不是将模型静态绑定到xml.

我也发现这个问题确实存在同样的问题但是由于数据绑定是在较新版本的android中发布的,我正在寻找一种方法来解决使用数据绑定的相同问题.以下是我引用澄清的问题的一部分:

例如,我有一个精心设计的布局,我希望在我的视图中显示三次.每个实例都需要不同的值.由于include基本上是XML并将其粘贴到此处,因此我需要更强大的功能.

xml android android-layout android-databinding

28
推荐指数
2
解决办法
2万
查看次数

如何停止更改焦点时自动显示软键盘(OnStart事件)

我正在开发使用Android 2.2的平板电脑.

我有一个表单,我用于新的和可编辑的实例.可编辑时,我想阻止用户编辑某些字段.我在我的onStart-event中设置了这个,设置了txt.setFocusableInTouchMode(false).这会强制焦点转到下一个可聚焦EditText的形式(这很棒),但在运行时,软键盘会自动显示EditText焦点.谁知道如何制止这个?

这是代码(在onStart事件中调用):

private void PopulateFields(){
    TextView txtTitle = (TextView) this.findViewById(R.id.txtEquipmentEditTitle);
    AutoCompleteTextView txtMake = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditMake);
    AutoCompleteTextView txtModel = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditModel);
    EditText txtDesc = (EditText) this.findViewById(R.id.txtEquipmentEditDesc);
    TextView txtDeptKey = (TextView) this.findViewById(R.id.txtEquipmentEditDeptKey);
    EditText txtSerial = (EditText) this.findViewById(R.id.txtEquipmentEditSerialNo);
    EditText txtBarCode = (EditText) this.findViewById(R.id.txtEquipmentEditBarCode);

    txtTitle.setText("Edit Equipment");
    txtMake.setText(make);
    txtModel.setText(model);
    txtDesc.setText(desc);
    txtDeptKey.setText(Integer.toString(deptKey));
    txtSerial.setText(serial);
    txtBarCode.setText(barCode);
    txtMake.setEnabled(false);
    txtModel.setEnabled(false);
    txtDesc.setEnabled(false);
    txtMake.setClickable(false);
    txtMake.setFocusableInTouchMode(false);
    txtModel.setFocusableInTouchMode(false);
    txtDesc.setFocusableInTouchMode(false);
    txtMake.setFocusable(false);
    txtModel.setFocusable(false);
    txtDesc.setFocusable(false);
}
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard android-edittext

27
推荐指数
3
解决办法
3万
查看次数