92 lines
3.3 KiB
Java
92 lines
3.3 KiB
Java
package com.gh.gamecenter;
|
|
|
|
import android.content.Intent;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
|
|
import com.gh.base.BaseActivity;
|
|
import com.gh.common.util.PlatformUtils;
|
|
import com.gh.common.util.RunningUtils;
|
|
|
|
/**
|
|
* Created by LGT on 2016/11/16.
|
|
* 链接跳转用
|
|
*/
|
|
public class SkipActivity extends BaseActivity {
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
if (getIntent() != null) {
|
|
String host = getIntent().getData().getHost();
|
|
String id = getIntent().getData().getPath();
|
|
if (!TextUtils.isEmpty(id)) {
|
|
id = id.substring(1);
|
|
}
|
|
Intent intent = new Intent();
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
intent.putExtra("entrance", "(浏览器)");
|
|
if (RunningUtils.isRunning(this)
|
|
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
|
// 应用正在运行,前台或后台
|
|
if ("article".equals(host)) {
|
|
intent.setClass(this, NewsDetailActivity.class);
|
|
intent.putExtra("newsId", id);
|
|
} else if ("game".equals(host)) {
|
|
intent.setClass(this, GameDetailActivity.class);
|
|
intent.putExtra("gameId", id);
|
|
} else if ("column".equals(host)) {
|
|
intent.setClass(this, SubjectActivity.class);
|
|
intent.putExtra("id", id);
|
|
intent.putExtra("name", getIntent().getData().getQueryParameter("name"));
|
|
} else if ("suggestion".equals(host)) {
|
|
Uri uri = getIntent().getData();
|
|
String content = "【" + uri.getQueryParameter("game_name")
|
|
+ "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform"))
|
|
+ "-V" + uri.getQueryParameter("version") + "】";
|
|
intent.putExtra("content", content);
|
|
intent.setClass(this, SuggestionActivity.class);
|
|
} else if ("download".equals(host)) {
|
|
intent.setClass(this, DownloadManagerActivity.class);
|
|
intent.putExtra("gameId", id);
|
|
intent.putExtra("packageName", getIntent().getData().getQueryParameter("packageName"));
|
|
}
|
|
} else {
|
|
// 应用未在运行
|
|
intent.setClass(this, SplashScreenActivity.class);
|
|
intent.setAction(Intent.ACTION_MAIN);
|
|
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
|
|
|
if ("article".equals(host)) {
|
|
intent.putExtra("newsId", id);
|
|
intent.putExtra("to", "NewsDetailActivity");
|
|
} else if ("game".equals(host)) {
|
|
intent.putExtra("gameId", id);
|
|
intent.putExtra("to", "GameDetailActivity");
|
|
} else if ("column".equals(host)) {
|
|
intent.putExtra("to", "SubjectActivity");
|
|
intent.putExtra("id", id);
|
|
intent.putExtra("name", getIntent().getData().getQueryParameter("name"));
|
|
} else if ("suggestion".equals(host)) {
|
|
Uri uri = getIntent().getData();
|
|
String content = "【" + uri.getQueryParameter("game_name")
|
|
+ "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform"))
|
|
+ "-V" + uri.getQueryParameter("version") + "】";
|
|
intent.putExtra("content", content);
|
|
intent.putExtra("to", "SuggestionActivity");
|
|
} else if ("download".equals(host)) {
|
|
intent.putExtra("to", "DownloadManagerActivity");
|
|
intent.putExtra("gameId", id);
|
|
intent.putExtra("packageName", getIntent().getData().getQueryParameter("packageName"));
|
|
}
|
|
}
|
|
startActivity(intent);
|
|
}
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|