Example usage for android.app Activity getClassLoader

List of usage examples for android.app Activity getClassLoader

Introduction

In this page you can find the example usage for android.app Activity getClassLoader.

Prototype

@Override
    public ClassLoader getClassLoader() 

Source Link

Usage

From source file:org.xwalk.runtime.extension.XWalkExtensionManager.java

private Object createExtensionContextClient(XWalkExtensionContextWrapper contextWrapper) {
    Activity activity = contextWrapper.getActivity();
    try {// w  ww  .  j  a v a2 s.c o  m
        Class<?> clazz = activity.getClassLoader().loadClass(EXTENSION_CONTEXT_CLIENT_CLASS_NAME);
        Constructor<?> constructor = clazz.getConstructor(Activity.class, Object.class);
        return constructor.newInstance(activity, contextWrapper);
    } catch (ClassNotFoundException e) {
        handleException(e);
    } catch (IllegalAccessException e) {
        handleException(e);
    } catch (InstantiationException e) {
        handleException(e);
    } catch (InvocationTargetException e) {
        handleException(e);
    } catch (NoSuchMethodException e) {
        handleException(e);
    }
    return null;
}

From source file:org.xwalk.runtime.extension.XWalkExtensionManager.java

private void createExternalExtension(String name, String className, String jsApi, Object contextClient,
        XWalkExtensionContextWrapper contextWrapper) {
    Activity activity = contextWrapper.getActivity();
    try {/*w ww  .j a  va  2s.  c  om*/
        Class<?> clazz = activity.getClassLoader().loadClass(className);
        Constructor<?> constructor = clazz.getConstructor(String.class, String.class, contextClient.getClass());
        constructor.newInstance(name, jsApi, contextClient);
    } catch (ClassNotFoundException e) {
        handleException(e);
    } catch (IllegalAccessException e) {
        handleException(e);
    } catch (InstantiationException e) {
        handleException(e);
    } catch (InvocationTargetException e) {
        handleException(e);
    } catch (NoSuchMethodException e) {
        handleException(e);
    }
}

From source file:android.app.FragmentState.java

public Fragment instantiate(Activity activity, Fragment parent) {
    if (mInstance != null) {
        return mInstance;
    }//  www. j a v a  2s .c om

    if (mArguments != null) {
        mArguments.setClassLoader(activity.getClassLoader());
    }

    mInstance = Fragment.instantiate(activity, mClassName, mArguments);

    if (mSavedFragmentState != null) {
        mSavedFragmentState.setClassLoader(activity.getClassLoader());
        mInstance.mSavedFragmentState = mSavedFragmentState;
    }
    mInstance.setIndex(mIndex, parent);
    mInstance.mFromLayout = mFromLayout;
    mInstance.mRestored = true;
    mInstance.mFragmentId = mFragmentId;
    mInstance.mContainerId = mContainerId;
    mInstance.mTag = mTag;
    mInstance.mRetainInstance = mRetainInstance;
    mInstance.mDetached = mDetached;
    mInstance.mFragmentManager = activity.mFragments;
    if (FragmentManagerImpl.DEBUG)
        Log.v(FragmentManagerImpl.TAG, "Instantiated fragment " + mInstance);

    return mInstance;
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void openStatus(final Activity activity, final ParcelableStatus status) {
    if (activity == null || status == null)
        return;/*w w w.ja va  2s  .c  o  m*/
    final long account_id = status.account_id, status_id = status.id;
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_STATUS, status);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_TWITTNUKER);
    builder.authority(AUTHORITY_STATUS);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
    builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(activity.getClassLoader());
    intent.putExtras(extras);
    SwipebackActivityUtils.startSwipebackActivity(activity, intent);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void openUserProfile(final Activity activity, final ParcelableUser user) {
    if (activity == null || user == null)
        return;// www.ja va  2 s .c  o  m
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER, user);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_TWITTNUKER);
    builder.authority(AUTHORITY_USER);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(user.account_id));
    if (user.id > 0) {
        builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user.id));
    }
    if (user.screen_name != null) {
        builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, user.screen_name);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(activity.getClassLoader());
    intent.putExtras(extras);
    SwipebackActivityUtils.startSwipebackActivity(activity, intent);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void openUserListDetails(final Activity activity, final ParcelableUserList userList) {
    if (activity == null || userList == null)
        return;/*from w  w  w. ja va2s .c  o m*/
    final long accountId = userList.account_id, userId = userList.user_id;
    final long listId = userList.id;
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER_LIST, userList);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_TWITTNUKER);
    builder.authority(AUTHORITY_USER_LIST);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(activity.getClassLoader());
    intent.putExtras(extras);
    SwipebackActivityUtils.startSwipebackActivity(activity, intent);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserListDetails(final Activity activity, final ParcelableUserList userList) {
    if (activity == null || userList == null)
        return;/*ww  w .  java 2s . c o m*/
    final long accountId = userList.account_id, userId = userList.user_id;
    final long listId = userList.id;
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER_LIST, userList);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(activity.getClassLoader());
    intent.putExtras(extras);
    activity.startActivity(intent);
}