Android Open Source - dynamic-load-apk Main Activity






From Project

Back to project page dynamic-load-apk.

License

The source code is released under:

Apache License

If you think the Android project dynamic-load-apk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ryg.dynamicload.sample.mainplugin;
//w w w.j  a va2  s  .  co  m
import com.ryg.dynamicload.DLBasePluginActivity;
import com.ryg.dynamicload.internal.DLIntent;
import com.ryg.dynamicload.sample.mainplugina.R;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

public class MainActivity extends DLBasePluginActivity {

    private static final String TAG = "Client-MainActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView(savedInstanceState);
    }

    private void initView(Bundle savedInstanceState) {
        that.setContentView(generateContentView(that));
    }

    private View generateContentView(final Context context) {
        LinearLayout layout = new LinearLayout(context);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        layout.setBackgroundColor(Color.parseColor("#F79AB5"));
        Button button = new Button(context);
        button.setText("Start TestActivity");
        layout.addView(button, LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "you clicked button",
                        Toast.LENGTH_SHORT).show();
                DLIntent intent = new DLIntent(getPackageName(), TestFragmentActivity.class);
                intent.putExtra("dl_extra", "from DL framework");
                startPluginActivityForResult(intent, 0);
            }
        });
        return layout;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult resultCode=" + resultCode);
        if (resultCode == RESULT_FIRST_USER) {
            that.finish();
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}




Java Source Code List

com.ryg.dynamicload.DLBasePluginActivity.java
com.ryg.dynamicload.DLBasePluginFragmentActivity.java
com.ryg.dynamicload.DLPlugin.java
com.ryg.dynamicload.DLProxyActivity.java
com.ryg.dynamicload.DLProxyFragmentActivity.java
com.ryg.dynamicload.internal.DLIntent.java
com.ryg.dynamicload.internal.DLPluginManager.java
com.ryg.dynamicload.internal.DLPluginPackage.java
com.ryg.dynamicload.internal.DLProxyImpl.java
com.ryg.dynamicload.sample.docommon.HostInterfaceManager.java
com.ryg.dynamicload.sample.docommon.HostInterface.java
com.ryg.dynamicload.sample.doihost.MainActivity.java
com.ryg.dynamicload.sample.doihost.component.HostComponent.java
com.ryg.dynamicload.sample.doihost.interfacee.HostInterfaceImp.java
com.ryg.dynamicload.sample.doiplugin.MainActivity.java
com.ryg.dynamicload.sample.mainhost.MainActivity.java
com.ryg.dynamicload.sample.mainhost.TestHostClass.java
com.ryg.dynamicload.sample.mainplugin.MainActivity.java
com.ryg.dynamicload.sample.mainplugin.ResourceConstants.java
com.ryg.dynamicload.sample.mainplugin.TestButton.java
com.ryg.dynamicload.sample.mainplugin.TestFragmentActivity.java
com.ryg.dynamicload.sample.mainplugin.TestFragment.java
com.ryg.dynamicload.sample.mainpluginb.MainActivity.java
com.ryg.utils.DLConstants.java
com.ryg.utils.DLUtils.java