Java Code Examples for android.content.Intent.setExtrasClassLoader()

The following are Jave code examples for showing how to use setExtrasClassLoader() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: nifi-android-s2s   File: SiteToSiteRepeating.java   View Source Code Vote up 7 votes
private static Intent getIntent(Context context, IntentType intentType, DataCollector dataCollector, SiteToSiteClientConfig siteToSiteClientConfig, Integer requestCode, Parcelable transactionResultCallback) {
    Intent intent = new Intent(context, SiteToSiteRepeating.class);
    if (dataCollector != null) {
        intent.setExtrasClassLoader(dataCollector.getClass().getClassLoader());
    } else if (transactionResultCallback != null) {
        intent.setExtrasClassLoader(transactionResultCallback.getClass().getClassLoader());
    } else {
        intent.setExtrasClassLoader(siteToSiteClientConfig.getClass().getClassLoader());
    }
    intent.putExtra(SiteToSiteService.INTENT_TYPE, intentType.name());

    if (requestCode == null) {
        // Find unused requestCode
        PendingIntent existing;
        do {
            requestCode = random.nextInt();
            existing = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_NO_CREATE);
        } while (existing != null);
    }

    intent.putExtra(REQUEST_CODE, requestCode);
    SerializationUtils.putParcelable(dataCollector, intent, DATA_COLLECTOR);
    SerializationUtils.putParcelable(transactionResultCallback, intent, SiteToSiteService.TRANSACTION_RESULT_CALLBACK);
    SerializationUtils.putParcelable(siteToSiteClientConfig, intent, SiteToSiteService.SITE_TO_SITE_CONFIG);
    return intent;
}
 
Example 2
Project: GitJourney   File: StackWidgetService.java   View Source Code Vote up 7 votes
public StackRemoteViewsFactory(Context applicationContext, Intent intent) {
    Log.v(TAG, "StackRemoteViewsFactory");
    intent.setExtrasClassLoader(GitHubJourneyWidgetDataEntry.class.getClassLoader());
    this.context = applicationContext;
    appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 1);
    Bundle bundle = intent.getBundleExtra("bundle");
    Parcelable[] items = bundle.getParcelableArray("parcelables");
    Log.v(TAG, "items size = " + items.length);

    if (items.length != 0) {
        widgetDatas = new ArrayList<>(items.length);
        for (Parcelable item : items) {
            widgetDatas.add((GitHubJourneyWidgetDataEntry) item);
        }
    } else {
        widgetDatas = new ArrayList<>(0);
    }
    Log.v(TAG, "widgetDatas" + widgetDatas.size());
}
 
Example 3
Project: letv   File: ServcesManager.java   View Source Code Vote up 7 votes
private void handleOnStartOne(Intent intent, int flags, int startIds) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = (Service) this.mNameService.get(info.name);
        if (service != null) {
            intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
            Object token = findTokenByService(service);
            Integer integer = (Integer) this.mServiceTaskIds.get(token);
            if (integer == null) {
                integer = Integer.valueOf(-1);
            }
            int startId = integer.intValue() + 1;
            this.mServiceTaskIds.put(token, Integer.valueOf(startId));
            int res = service.onStartCommand(intent, flags, startId);
            QueuedWorkCompat.waitToFinish();
        }
    }
}
 
Example 4
Project: VirtualAPK   File: VAInstrumentation.java   View Source Code Vote up 7 votes
@Override
public boolean handleMessage(Message msg) {
    if (msg.what == LAUNCH_ACTIVITY) {
        // ActivityClientRecord r
        Object r = msg.obj;
        try {
            Intent intent = (Intent) ReflectUtil.getField(r.getClass(), r, "intent");
            intent.setExtrasClassLoader(VAInstrumentation.class.getClassLoader());
            ActivityInfo activityInfo = (ActivityInfo) ReflectUtil.getField(r.getClass(), r, "activityInfo");

            if (PluginUtil.isIntentFromPlugin(intent)) {
                int theme = PluginUtil.getTheme(mPluginManager.getHostContext(), intent);
                if (theme != 0) {
                    Log.i(TAG, "resolve theme, current theme:" + activityInfo.theme + "  after :0x" + Integer.toHexString(theme));
                    activityInfo.theme = theme;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return false;
}
 
Example 5
Project: springreplugin   File: PmHostSvc.java   View Source Code Vote up 7 votes
private void sendIntent2Process(String target, Intent intent, boolean sync) throws RemoteException {
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "sendIntent2Process target=" + target + " intent=" + intent);
    }

    if (TextUtils.equals(target, IPC.getPluginHostProcessName())) {
        intent.setExtrasClassLoader(getClass().getClassLoader());
        if (sync) {
            LocalBroadcastHelper.sendBroadcastSyncUi(mContext, intent);
        } else {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
        }
        return;
    }

    if (TextUtils.isEmpty(target)) {
        intent.setExtrasClassLoader(getClass().getClassLoader());
        if (sync) {
            LocalBroadcastHelper.sendBroadcastSyncUi(mContext, intent);
        } else {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
        }
    }
    PluginProcessMain.sendIntent2Process(target, intent, sync);
}
 
Example 6
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 7 votes
private void handleOnStartOne(Intent intent, int flags, int startIds) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            Object token = findTokenByService(service);
            Integer integer = mServiceTaskIds.get(token);
            if (integer == null) {
                integer = -1;
            }
            int startId = integer + 1;
            mServiceTaskIds.put(token, startId);
            int res = service.onStartCommand(intent, flags, startId);
            QueuedWorkCompat.waitToFinish();
        }
    }
}
 
Example 7
Project: atlas   File: BaseDelegateService.java   View Source Code Vote up 6 votes
private void handleServiceArgs(Intent serviceIntent,IBinder token){
    Service service = mActivateServices.get(token);
    if(service!=null){
        if(serviceIntent!=null) {
            serviceIntent.setExtrasClassLoader(service.getClassLoader());
        }
        service.onStartCommand(serviceIntent,Service.START_FLAG_RETRY,0);
    }
}
 
Example 8
Project: letv   File: ServcesManager.java   View Source Code Vote up 6 votes
private void handleOnTaskRemovedOne(Intent intent) throws Exception {
    if (VERSION.SDK_INT >= 14) {
        ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            Service service = (Service) this.mNameService.get(info.name);
            if (service != null) {
                intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
                service.onTaskRemoved(intent);
                QueuedWorkCompat.waitToFinish();
            }
            QueuedWorkCompat.waitToFinish();
        }
    }
}
 
Example 9
Project: letv   File: ServcesManager.java   View Source Code Vote up 6 votes
private IBinder handleOnBindOne(Intent intent) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = (Service) this.mNameService.get(info.name);
        if (service != null) {
            intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
            return service.onBind(intent);
        }
    }
    return null;
}
 
Example 10
Project: letv   File: ServcesManager.java   View Source Code Vote up 6 votes
private void handleOnRebindOne(Intent intent) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = (Service) this.mNameService.get(info.name);
        if (service != null) {
            intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
            service.onRebind(intent);
        }
    }
}
 
Example 11
Project: letv   File: ServcesManager.java   View Source Code Vote up 6 votes
private boolean handleOnUnbindOne(Intent intent) throws Exception {
    ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
    if (info == null) {
        return false;
    }
    Service service = (Service) this.mNameService.get(info.name);
    if (service == null) {
        return false;
    }
    intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
    return service.onUnbind(intent);
}
 
Example 12
Project: springreplugin   File: PluginProcessPer.java   View Source Code Vote up 6 votes
private void sendIntent(Intent intent, boolean sync) throws RemoteException {
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "sendIntent pr=" + IPC.getCurrentProcessName() + " intent=" + intent);
    }
    intent.setExtrasClassLoader(getClass().getClassLoader());
    if (sync) {
        LocalBroadcastHelper.sendBroadcastSyncUi(mContext, intent);
    } else {
        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
    }
}
 
Example 13
Project: springreplugin   File: PluginLibraryInternalProxy.java   View Source Code Vote up 6 votes
/**
 * @hide 内部方法,插件框架使用
 * 插件的Activity的onCreate调用前调用此方法
 * @param activity
 * @param savedInstanceState
 */
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
    }

    // 对FragmentActivity做特殊处理
    if (savedInstanceState != null) {
        //
        savedInstanceState.setClassLoader(activity.getClassLoader());
        //
        try {
            savedInstanceState.remove("android:support:fragments");
        } catch (Throwable e) {
            if (LOGR) {
                LogRelease.e(PLUGIN_TAG, "a.c.b1: " + e.getMessage(), e);
            }
        }
    }

    // 对FragmentActivity做特殊处理
    Intent intent = activity.getIntent();
    if (intent != null) {
        intent.setExtrasClassLoader(activity.getClassLoader());
        activity.setTheme(getThemeId(activity, intent));
    }
}
 
Example 14
Project: DroidPlugin   File: IActivityManagerHookHandle.java   View Source Code Vote up 6 votes
private void setIntentClassLoader(Intent intent, ClassLoader classLoader) {
    try {
        Bundle mExtras = (Bundle) FieldUtils.readField(intent, "mExtras");
        if (mExtras != null) {
            mExtras.setClassLoader(classLoader);
        } else {
            Bundle value = new Bundle();
            value.setClassLoader(classLoader);
            FieldUtils.writeField(intent, "mExtras", value);
        }
    } catch (Exception e) {
    } finally {
        intent.setExtrasClassLoader(classLoader);
    }
}
 
Example 15
Project: DroidPlugin   File: PluginCallback.java   View Source Code Vote up 6 votes
private void setIntentClassLoader(Intent intent, ClassLoader classLoader) {
    try {
        Bundle mExtras = (Bundle) FieldUtils.readField(intent, "mExtras");
        if (mExtras != null) {
            mExtras.setClassLoader(classLoader);
        } else {
            Bundle value = new Bundle();
            value.setClassLoader(classLoader);
            FieldUtils.writeField(intent, "mExtras", value);
        }
    } catch (Exception e) {
    } finally {
        intent.setExtrasClassLoader(classLoader);
    }
}
 
Example 16
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 6 votes
private void handleOnTaskRemovedOne(Intent intent) throws Exception {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            Service service = mNameService.get(info.name);
            if (service != null) {
                ClassLoader classLoader = getClassLoader(info.applicationInfo);
                intent.setExtrasClassLoader(classLoader);
                service.onTaskRemoved(intent);
                QueuedWorkCompat.waitToFinish();
            }
            QueuedWorkCompat.waitToFinish();
        }
    }
}
 
Example 17
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 6 votes
private IBinder handleOnBindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            return service.onBind(intent);
        }
    }
    return null;
}
 
Example 18
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 6 votes
private void handleOnRebindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            service.onRebind(intent);
        }
    }
}
 
Example 19
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 6 votes
private boolean handleOnUnbindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            return service.onUnbind(intent);
        }
    }
    return false;
}