【问题标题】:Launching Play Store when connecting USB (or BLE) device连接 USB(或 BLE)设备时启动 Play Store
【发布时间】:2014-09-02 10:03:09
【问题描述】:

有谁知道第一次在 Android 手机或平板电脑上通过 USB(或 BLE)连接设备时是否可以自动打开 Play 商店? 目的是确保用户在第一次连接新设备(例如 MIDI 键盘或其他)时安装捆绑的应用程序。它显然必须是 Android 操作系统的一部分(哪个版本?)

谢谢

【问题讨论】:

  • @raj 证明这一点(你的回答没有解决我的问题)。

标签: android usb bluetooth-lowenergy google-play


【解决方案1】:

首先从下面复制 bradcastrecieverclass

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbManager;

public class Usbinserted extends BroadcastReceiver {

@Override
public void onReceive(Context ctx, Intent intent) {
    // TODO Auto-generated method stub


             Intent i = new Intent(Intent.ACTION_MAIN, null);

             i.addCategory(Intent.CATEGORY_LAUNCHER);

             ComponentName cn = new ComponentName(
                "com.google.android.finsky.FinskyApp",
                "com.google.android.finsky.FinskyApp.AssetBrowserActivity");

            i.setComponent(cn);

            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            ctx.startActivity(i);

 //  Log.d(TAG,"USB connected..");


}

}

现在将其复制并粘贴到您的清单文件中

 <receiver android:name=".Usbinserted" >
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            <action android:name="android.intent.action.MEDIA_MOUNTED" />
            <action android:name="android.intent.action.UMS_CONNECTED" />
            <action android:name="android.intent.action.USB_ACCESSORY_ATTACHED" /> <data android:scheme="file"/>
        </intent-filter>
    </receiver>

并将这些权限添加到清单文件

 <uses-feature android:name="android.hardware.usb.host" />
 <uses-permission android:name="android.permission.USB_PERMISSION" />

【讨论】:

  • 你没有回答我的问题。最初没有安装任何应用程序。问题是自动触发与 Play 商店的连接以下载我的应用程序。
  • 因为你需要安装一个包含广播接收器的应用程序
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-10
  • 1970-01-01
  • 1970-01-01
  • 2011-11-02
相关资源
最近更新 更多