Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid USB attached Status;
    primarykey
    data
    text
    <p>I want to do the replication between SQL SERVER &amp; SQLite.ITs wroking with WIFI netconnection.</p> <p>My Problem is: Network priority USB(Connect to PC),GPRS,WIFI. This is the prioprity order. Wifi &amp; GPRS are ok. USB is a problem. How can i identiify Android device attached to PC.</p> <pre><code> public class DownlaodTableActivity extends Activity{ private int networkType; private int signalStrengthInt; private SignalStrength signalStrength; private TelephonyManager telephonyInfo; static boolean usbStatus = false; public static BroadcastReceiver mReceiver1 = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Toast.makeText(context, context.toString(),Toast.LENGTH_LONG).show(); String action = intent.getAction(); if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) { Toast.makeText(context, "SD Card mounted",Toast.LENGTH_LONG).show(); } else if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) { Toast.makeText(context, "SD Card unmounted",Toast.LENGTH_LONG).show(); } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) { Toast.makeText(context, "SD Card scanner started",Toast.LENGTH_LONG).show(); } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) { Toast.makeText(context, "SD Card scanner finished",Toast.LENGTH_LONG).show(); } else if (action.equals(Intent.ACTION_MEDIA_EJECT)) { Toast.makeText(context, "SD Card eject",Toast.LENGTH_LONG).show(); } else if(action.equals(Intent.ACTION_UMS_CONNECTED)){ Toast.makeText(context, "connected",Toast.LENGTH_LONG).show(); usbStatus =true; } else if(action.equals(Intent.ACTION_UMS_DISCONNECTED)) { Toast.makeText(context, "disconnected",Toast.LENGTH_LONG).show(); usbStatus =false; } if(UsbManager.ACTION_USB_ACCESSORY_ATTACHED.equals(action)) { usbStatus =true; }else{ usbStatus =false; } int level = intent.getIntExtra("level", 0); Toast.makeText(context, "Battery Level is :"+level+" Please plugin charger!!!",Toast.LENGTH_LONG).show(); context.unregisterReceiver(this); int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); int levels = -1; if (rawlevel &gt;= 0 &amp;&amp; scale &gt; 0) { levels = (rawlevel * 100) / scale; } Toast.makeText(context, "Battery Level Remaining:"+levels+" %",Toast.LENGTH_LONG).show(); } }; manager = (ConnectivityManager) getSystemService(DownlaodTableActivity.CONNECTIVITY_SERVICE); is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected(); isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); telephonyInfo = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyInfo.listen(phoneState,PhoneStateListener.LISTEN_SIGNAL_STRENGTH); networkType = telephonyInfo.getNetworkType(); if (usbStatus) {................} else if (isWifi||is3g) { ................} else if(networkType==TelephonyManager.NETWORK_TYPE_EDGE) { ...........} </code></pre> <p>And My Manifest file:</p> <pre><code> &lt;receiver android:name=".admin.mReceiver1"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.ums_connected" /&gt; &lt;action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /&gt; &lt;action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" /&gt; &lt;meta-data android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" android:resource="@xml/device_filter" /&gt; &lt;/receiver&gt; </code></pre> <p>I tried this ways also ... <a href="http://pastie.org/3019828" rel="nofollow">http://pastie.org/3019828</a></p> <p>Please Tell me Why it didn't take USBSttaus =true; I connected Android in PC.But still it show usb device sttached status is false.</p> <p>Please help out from this question.</p> <p>Thanks in advance;</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload