Code example for Context

Methods: getBroadcastgetSystemServiceregisterReceiver

0
     * 
     * @param context the {@link android.content.Context} to use for the MtpClient 
     */ 
    public MtpClient(Context context) {
        mContext = context;
        mUsbManager = (UsbManager)context.getSystemService(Context.USB_SERVICE);
        mPermissionIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), 0);
        IntentFilter filter = new IntentFilter();
        filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
        filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        filter.addAction(ACTION_USB_PERMISSION);
        context.registerReceiver(mUsbReceiver, filter);
    } 
 
    /** 
     * Opens the {@link android.hardware.usb.UsbDevice} for an MTP or PTP 
     * device and return an {@link android.mtp.MtpDevice} for it. 
     * 
     * @param device the device to open 
     * @return an MtpDevice for the device. 
Stop searching for code, let great code find you!  Add Codota to your java IDE