微信跳转App

下载相应的SDK : http://www.openinstall.io/download.html

dependencies {
    compile files('libs/OpenInstall_vX.X.X.jar')
}

在AndroidMaifest.xml中添加权限声明



在AndroidMaifest.xml中设置AppKey


初始化SDK

public class MyApplication extends Application {
        @Override
        public void onCreate() {
            super.onCreate();
             OpenInstall.init(this);
             //打开调试,便于看到Log
             OpenInstall.setDebug(true);
        }
}
在AndroidMaifest.xml的唤醒页面activity标签中添加intent-filter


        
              
              
              
              
        
在应用启动页如下调用相关代码,获取安装参数/渠道参数

public class SplashActivity extends BaseActivity implements AppInstallListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);
            //获取OpenInstall数据
            OpenInstall.getInstall(this);
    }
    @Override
    public void onInstallFinish(AppData appData, Error error) {
            if (error == null) {
                //获取渠道数据
                Log.d("SplashActivity", "channel = " + appData.getChannel());
                //获取个性化安装数据
                Log.d("SplashActivity", "install = " + appData.getData());
            } else {
                Log.d("SplashActivity", "error : "+error.toString());
            }
    }
}

一键跳转集成  在唤醒页面如下调用相关代码,获取web端传过来的参数

public class MainActivity extends BaseActivity implements AppWakeUpListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            OpenInstall.getWakeUp(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
            setIntent(intent);
            //此处要调用,否则App在后台运行时,会无法截获
            OpenInstall.getWakeUp(intent, this);
    }
    @Override
    public void onWakeUpFinish(AppData appData, Error error) {
            if (error == null) {
                Log.d("MainActivity", "wakeup = " + appData.toString());
            } else {
                Log.d("MainActivity", "error : "+error.toString());
            }
    }
}


你可能感兴趣的:(android)