Android PathClassLoader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PathClassLoader class.

This code example shows how to use the following methods:findLibrary
        File applicationLibPath = new File(tmp, "applicationLibPath");
        makeTempFile(systemLibPath, "libduplicated.so");
        File applicationLib = makeTempFile(applicationLibPath, "libduplicated.so");
 
        System.setProperty("java.library.path", systemLibPath.toString());
        PathClassLoader pathClassLoader = new PathClassLoader(applicationLibPath.toString(),
                applicationLibPath.toString(), getClass().getClassLoader());
 
        String path = pathClassLoader.findLibrary("duplicated");
        assertEquals(applicationLib.toString(), path);
    } 
 
    private File makeTempFile(File directory, String name) throws IOException {
        directory.mkdirs();
        File result = new File(directory, name);
        FileOutputStream stream = new FileOutputStream(result);
        stream.close();
        assertTrue(result.exists());
        return result;
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:findLibrary
        File applicationLibPath = new File(tmp, "applicationLibPath");
        makeTempFile(systemLibPath, "libduplicated.so");
        File applicationLib = makeTempFile(applicationLibPath, "libduplicated.so");
 
        System.setProperty("java.library.path", systemLibPath.toString());
        PathClassLoader pathClassLoader = new PathClassLoader(applicationLibPath.toString(),
                applicationLibPath.toString(), getClass().getClassLoader());
 
        String path = pathClassLoader.findLibrary("duplicated");
        assertEquals(applicationLib.toString(), path);
    } 
 
    private File makeTempFile(File directory, String name) throws IOException {
        directory.mkdirs();
        File result = new File(directory, name);
        FileOutputStream stream = new FileOutputStream(result);
        stream.close();
        assertTrue(result.exists());
        return result;
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    	if (!sWasHtcSenseTested) {
    		sWasHtcSenseTested = true;
 
    		try { 
	            // No we don't. Search for HTC Contacts Application class (HTC Sense) 
	            PathClassLoader classLoader =  new PathClassLoader(HTC_CONTACTS_APK_PATH,
	            		context.getClassLoader());
	            Class.forName(KNOWN_HTC_CONTACTS_CLASS, true, classLoader);
	             
	            sIsHtcSenseDevice = true;
            }  
            catch(Exception ex) {
            	sIsHtcSenseDevice = false;
            } 
       	} 
    	return sIsHtcSenseDevice;
    } 
     
    /** 
     * Returns the version name from the AndroidManifest.xml file. 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    private static void initClassLoader(final Context ctx) throws NameNotFoundException {
        if (stubClassLoader != null) {
            return; 
        } 
        ApplicationInfo vpnAppInfo = ctx.getPackageManager().getApplicationInfo(STUB_PACK, 0);
        stubClassLoader = new PathClassLoader(vpnAppInfo.sourceDir, ClassLoader.getSystemClassLoader());
    } 
 
    protected static final Class<?> loadClass(final String qname) throws ClassNotFoundException {
            return Class.forName(qname, true, stubClassLoader);
    } 
 
    @SuppressWarnings("unchecked") 
    protected <T> T invokeStubMethod(final String methodName, final Object... args) {
        try { 
            Method method = findStubMethod(methodName, args);
            return (T) method.invoke(stub, args);
        } catch (Exception e) {
            throw new WrapperException("failed to invoke mehod '" + methodName + "' on stub", e);
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
 
public class CustomPasswordDigest implements PasswordDigest { 
 
    private PasswordDigest mPasswordDigest;
    public CustomPasswordDigest(String pluginPath, String implClass) throws ImException {
        PathClassLoader classLoader = new PathClassLoader(pluginPath,
                getClass().getClassLoader());
        try { 
            Class<?> cls = classLoader.loadClass(implClass);
            mPasswordDigest = (PasswordDigest)cls.newInstance();
        } catch (ClassNotFoundException e) {
            throw new ImException(e);
        } catch (IllegalAccessException e) {
            throw new ImException(e);
        } catch (InstantiationException e) {
            throw new ImException(e);
        } 
    } 
    public String digest(String schema, String nonce, String password) throws ImException {
        return mPasswordDigest.digest(schema, nonce, password);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
 
public class CustomPresenceMapping implements PresenceMapping { 
    private PresenceMapping mPresenceMapping;
 
    public CustomPresenceMapping(String pluginPath, String implClass) throws ImException {
        PathClassLoader classLoader = new PathClassLoader(pluginPath,
                getClass().getClassLoader());
        try { 
            Class<?> cls = classLoader.loadClass(implClass);
            mPresenceMapping = (PresenceMapping)cls.newInstance();
        } catch (ClassNotFoundException e) {
            throw new ImException(e);
        } catch (IllegalAccessException e) {
            throw new ImException(e);
        } catch (InstantiationException e) {
            throw new ImException(e);
        } 
    } 
 
    public Map<String, Object> getExtra(int status) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
 
public class CustomPresenceMapping implements PresenceMapping { 
    private PresenceMapping mPresenceMapping;
 
    public CustomPresenceMapping(String pluginPath, String implClass) throws ImException {
        PathClassLoader classLoader = new PathClassLoader(pluginPath,
                getClass().getClassLoader());
        try { 
            Class<?> cls = classLoader.loadClass(implClass);
            mPresenceMapping = (PresenceMapping)cls.newInstance();
        } catch (ClassNotFoundException e) {
            throw new ImException(e);
        } catch (IllegalAccessException e) {
            throw new ImException(e);
        } catch (InstantiationException e) {
            throw new ImException(e);
        } 
    } 
 
    public Map<String, Object> getExtra(int status) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadClass
 
public class CustomPasswordDigest implements PasswordDigest { 
 
    private PasswordDigest mPasswordDigest;
    public CustomPasswordDigest(String pluginPath, String implClass) throws ImException {
        PathClassLoader classLoader = new PathClassLoader(pluginPath,
                getClass().getClassLoader());
        try { 
            Class<?> cls = classLoader.loadClass(implClass);
            mPasswordDigest = (PasswordDigest)cls.newInstance();
        } catch (ClassNotFoundException e) {
            throw new ImException(e);
        } catch (IllegalAccessException e) {
            throw new ImException(e);
        } catch (InstantiationException e) {
            throw new ImException(e);
        } 
    } 
    public String digest(String schema, String nonce, String password) throws ImException {
        return mPasswordDigest.digest(schema, nonce, password);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        if (parent == null)
            throw new IllegalStateException();
        //my_app, my_libraryをセパレータで区切ってdexPathを構成する 
        String dexPath = libraryCodePath + File.pathSeparator + context.getPackageCodePath();
        //dexPathを指定してPathClassLoaderを構成する 
        PathClassLoader customLoader = new PathClassLoader(dexPath,
                                                           parent);
        return customLoader;
    } 
 
    /** 
     * カスタムしたアプリケーションでActivityをロードする. 
     */ 
    @Override 
    public Activity newActivity(ClassLoader cl,
                                String className,
                                Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        return super.newActivity(getCustomLoader(getTargetContext()), className, intent);
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android PathClassLoader Questions & Answers:

See Code Examples for Android PathClassLoader Methods: