2013年5月31日星期五

MultiUserChat.addInvitationListener doesn't work

MultiUserChat.addInvitationListener doesn't work

You should add these codes before adding listener.

ProviderManager pm = ProviderManager.getInstance();
pm.addExtensionProvider("x", "
http://jabber.org/protocol/muc#user", new MUCUserProvider());


TAG: MultiUserChat.addInvitationListener doesn't work

android disable or turn off mass storage mode by code

android diable or turn off mass storage mode by code

Please add <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> first

try {
   Method method = Class.forName("android.os.ServiceManager")
     .getMethod("getService", String.class);// 利用反射得到ServiceManager类中的getService方法
   IBinder binder = (IBinder) method.invoke(null, "mount");
   Class<?> mIMountService = Class
     .forName("android.os.storage.IMountService");
   Class<?>[] classes = mIMountService.getClasses();// 获取IMountService的所有内部类
   Class<?> mStub = classes[0];// 获取IMountService的内部类Stub
   Method asInterface = mStub.getMethod("asInterface",
     new Class[] { IBinder.class });// 获取Stub的asInterface(IBinder
             // binder)方法,
   Object iMountService = asInterface.invoke(classes[0],
     new Object[] { binder });// 通过asInterface(IBinder
            // binder)方法获得IMountService类的一个实例对象mIMountService
   Class<?> mIMountServicer = iMountService.getClass(); // 通过实例对象获取Class对象
   Method setUsbMassStorageEnabled = mIMountServicer.getMethod(
     "setUsbMassStorageEnabled", new Class[] { boolean.class });
   Object result1 = setUsbMassStorageEnabled.invoke(iMountService, false);
  } catch (Exception e) {
   e.printStackTrace();
  }


tag: android disable or turn off mass storage mode by code