微信跳轉App
阿新 • • 發佈:2019-01-08
下載相應的SDK :http://www.openinstall.io/download.html
dependencies {
compile files('libs/OpenInstall_vX.X.X.jar')
}
在AndroidMaifest.xml中新增許可權宣告
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
在AndroidMaifest.xml中設定AppKey
<meta-data
android:name="com.openinstall.APP_KEY"
android:value="your AppKey" />
初始化SDK
在AndroidMaifest.xml的喚醒頁面activity標籤中新增intent-filterpublic class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); OpenInstall.init(this); //開啟除錯,便於看到Log OpenInstall.setDebug(true); } }
在應用啟動頁如下呼叫相關程式碼,獲取安裝引數/渠道引數<activity android:name=".MainActivity" android:launchMode="singleTask"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="your scheme"/> </intent-filter> </activity>
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());
}
}
}