小编iuq*_*iuq的帖子

如何在Android中以编程方式创建"水平样式"进度条?

我在我的应用程序中以编程方式创建了一个ProgressBar,默认情况下它是SPIN样式但是我希望它以HORIZONTAL样式.我没有看到任何方法/常量来实现这一点.

而且我不想使用ProgressDialog,因为它与我的App UI主题不一致.

有什么建议吗?

android android-progressbar android-styles

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

如何从浏览器控制手机屏幕?

更新
参考资料:perfecto mobile设备随处可见


我正在开发基于云的移动测试解决方案,该解决方案应该支持iOS和Android.它需要从浏览器处理连接的移动设备.

我了解到移动设备有一个代理程序类型的程序(需要设备根植)安装

  • 将移动屏幕流式传输到浏览器
  • 并注入事件

有没有其他方法可以实现这一点,可能没有root/jail打破设备?

这个问题可能看起来很广泛,但我一直在努力想要朝着正确的方向前进.

对于iOS,我从这个SOF问题中获取线索.

任何指针都很受欢迎.


更新1:
这个问题接近我正在寻找的问题.

更新2: 我找到了Android设备的Android屏幕库,并在几台设备上进行了测试.它不要求设备被植根,但需要在每次设备重启时从命令行重新启动服务,并且无法在Lollipop上运行它..

更新3: 虽然Android屏幕库有助于在没有生根的情况下捕获屏幕,但它对注入事件没有帮助.甚至屏幕捕获似乎有些错误 - 有时用黑色补丁捕获并且在棒棒糖上不起作用!

更新4: 参考:perfecto mobile设备随处可见 它们似乎ADB用于处理许多事情,如应用程序安装/卸载,通过发送事件adb shell input tap x y.任何人都可以解释一下吗?

更新5: 我也碰到过这种SO帖子阿德里安·泰勒,一名前工程师的RealVNC.这是最详细的解释.虽然Android Lollipop有MediaProjection API,但它似乎将屏幕截图存储为sdcard上的MP4文件.此外,根据谷歌仪表板 - 2015年8月更新Lollipop仍然是Android安装基数的15%左右,所以必须考虑Kitkat的任何解决方案.

更新6: 我找到了libvncserver,想知道它是否能完成这项工作.我将测试并发布结果.

谢谢

mobile android ios

9
推荐指数
1
解决办法
796
查看次数

ScrollView不显示顶部

问题:当ScrollView超出一定高度时,它会隐藏其子视图的顶部部分.

我有以下XML格式定义的布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/commandPanel"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingLeft="5dip"
        android:paddingRight="5dip" >

        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="OK" />

        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Back" />
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/mainContentPanel"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/commandPanel"
        android:background="@android:color/white" >

        <ScrollView
            android:id="@+id/formScrollView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_marginTop="5dip"
            android:layout_weight="1"
            android:background="@android:color/darker_gray"
            android:fillViewport="false"
            android:paddingBottom="5dip"
            android:scrollbarStyle="insideOverlay" >

            <LinearLayout
                android:id="@+id/formContentLayout"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center"
                android:layout_marginTop="20dip"
                android:background="@android:color/black"
                android:gravity="center_horizontal|top"
                android:orientation="vertical"
                android:paddingLeft="5dip"
                android:paddingRight="5dip"
                android:paddingTop="20dip" >

                <LinearLayout
                    android:id="@+id/tr"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:orientation="horizontal" >

                    <TextView
                        android:id="@+id/title"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="sample title" /> …
Run Code Online (Sandbox Code Playgroud)

android android-layout

8
推荐指数
1
解决办法
6243
查看次数

压缩后保持图像方向

这是我的代码

        //
        // reading an image captured using phone camera. Orientation of this
        // image is always return value 6 (ORIENTATION_ROTATE_90) no matter if
        // it is captured in landscape or portrait mode
        //
        Bitmap bmp = BitmapFactory.decodeFile(imagePath.getAbsolutePath());

        //
        // save as : I am compressing this image and writing it back. Orientation 
        //of this image always returns value 0 (ORIENTATION_UNDEFINED)
        imagePath = new File(imagePath.getAbsolutePath().replace(".jpg", "_1.jpg"));



        FileOutputStream fos0 = new FileOutputStream(imagePath);
        boolean b = bmp.compress(CompressFormat.JPEG, 10, fos0);
        fos0.flush();
        fos0.close();
        fos0 …
Run Code Online (Sandbox Code Playgroud)

android android-image

6
推荐指数
1
解决办法
4940
查看次数

XMLHttpRequest无法在模拟器上从android资源文件夹加载文件

我是混合动力开发的新手.我写了一个小应用程序启动webview.我有XML,JS文件复制在/ asset文件夹中.

应用程序在我的三星平板电脑上工作正常,但我在模拟器上得到以下错误

05-30 06:09:07.080:I/chromium(1245):[INFO:CONSOLE(0)]"XMLHttpRequest无法加载file:///android_asset/resource/service_config.xml.只有HTTP支持交叉原始请求. ",source:file:///android_asset/Startup.html(0)

我知道它发生的原因是Chrome浏览器安全模型和android webview也使用与chrome浏览器相同的组件.但所有这些主要与Chrome浏览器没有解决模拟器上的问题有关.

感谢您对此问题的任何帮助.

谢谢,
iuq

android android-emulator hybrid-mobile-app

6
推荐指数
1
解决办法
5214
查看次数

Android MediaProjection屏幕通过USB镜像到Web浏览器

我想将Android Screen镜像到桌面Web浏览器.我能够使用MediaProjection捕获屏幕 - 感谢示例应用程序.

但下一部分很难 - 将捕获的数据发送到桌面!我知道通过ADB端口转发建立到桌面程序的HTTP连接的技术,但我猜FPS将非常低.

如何将捕获的屏幕数据流式传输到桌面?我需要什么样的连接以及Android端需要哪些编解码器以确保速度?

谢谢

android video-streaming android-mediaprojection

6
推荐指数
0
解决办法
942
查看次数

如何从 Activity 与 HostApduService 进行通信

我在这里问了这个问题,但它被标记为重复 - 但是我没有找到评论中提到的任何有用的解决方案。在这里,我再次询问更多细节......

我正在HCE上制作一个示例应用程序 (PoC) ,并按照 Android 用户指南使用HostApduService 。我创建了两个应用程序
1) ReaderApp - 充当读卡器 2) HCEApp - 模拟卡

在 HCEApp 中,我创建了一个扩展 HostApduService 的类“MyService”

public class MyService extends HostApduService {

private int messageCounter;
private final String TAG = "MyService";

Intent mIntent;

@Override
public void onCreate() {
    super.onCreate();
    Log.i(TAG, "onCreate");

    mIntent = new Intent(this, MyActivity.class);
    mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(mIntent);
}

/**
 * returned bytes will be sent as response. This method runs in Main thread
 * so return ASAP.
 */

@Override …
Run Code Online (Sandbox Code Playgroud)

android android-service android-activity

5
推荐指数
1
解决办法
8331
查看次数

我的应用程序重新启动后房间数据丢失

我的应用程序中有一个 Room 的简单实现。它有两个实体。应用程序运行时它工作正常。但应用程序重新启动后我看不到任何数据。

这是我的数据库创建代码 -

@Database(entities = {Person.class, College.class}, version = 1,  exportSchema = true)
public abstract class AppDatabase extends RoomDatabase {
    private static AppdDatabase INSTANCE;
    public abstract PersonDao personDao();
    public abstract CollegeDao collgeDao();

    public static AppDatabase getInstance(Context context) {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, "my-sample-app.db")
                    .build();
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        if (INSTANCE != null) INSTANCE.close();
        INSTANCE = null;
    }
}
Run Code Online (Sandbox Code Playgroud)

在任何正在运行的会话中,我可以添加和查看数据,但应用程序重新启动后没有任何内容可用。我在这里缺少什么?

谢谢

android android-room

4
推荐指数
1
解决办法
4778
查看次数

java密码术中'AGCM256-KW'的算法字符串是什么,用于Cipher.getInstance(String算法)?

参考这个,我必须使用算法AGCM256-KW加密.我正在使用Java Cryptography,我没有找到任何这样的算法.我发现最接近的是AES_256/GCM/NoPadding,但它没有KW(密钥包装).

这是我的测试代码

    public void testEncryption(String algo) {
    String shared_secret = "LyQnklSrxsk3Ch2+AHi9HoDW@//x1LwM123QP/ln";
    try {

        // Step 1 - Create SHA-256 digest of the shared key
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        byte[] digest = md.digest(shared_secret.getBytes("UTF-8"));

        // Step 2 - generate a 256 bit Content Encryption Key(CEK)
        KeyGenerator kg = KeyGenerator.getInstance("AES");
        kg.init(256);
        SecretKey cek = kg.generateKey();

        // Step 3 - encrypt the CEK using 256 bit digest generated in Step 1
        // and 96 bit random IV. …
Run Code Online (Sandbox Code Playgroud)

java cryptography jwe jose4j

2
推荐指数
1
解决办法
1884
查看次数

Android无法加载打开的nfc插件

我按照这些说明在我的Windows 7系统上设置打开的nfc仿真器.根据指令#2,我已将Android nfc插件复制到我的Android SDK附加组件中.根据指令#3,我已经启动了AVD管理器来创建具有Open NFC附加组件作为目标的新AVD.

但我没有在目标列表中看到打开nfc加载项.在android SDK管理器中,在明智地对packeges存储库进行排序时,我可以看到onpe NFC附加图标已损坏,表示"Addon未能加载:null".请参见附件截图.

Android SDK管理器截图 已安装的组件列表开始 已安装的组件列表继续 已安装的组件列表结束

如果有人经历并解决了这个问题,请分享.

谢谢

android nfc open-nfc

1
推荐指数
1
解决办法
1628
查看次数