Fixed crash when open external uri

This commit is contained in:
PeratX 2017-06-18 09:26:58 +08:00
parent 8fdf99ca65
commit d36eee1859
3 changed files with 14 additions and 9 deletions

View File

@ -254,8 +254,16 @@ public class Daedalus extends Application {
}
public static void donate() {
instance.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://qr.alipay.com/a6x07022gffiehykicipv1a"))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
openUri("https://qr.alipay.com/a6x07022gffiehykicipv1a");
}
public static void openUri(String uri) {
try {
instance.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (Exception e) {
Logger.logException(e);
}
}
public static Daedalus getInstance() {

View File

@ -5,7 +5,6 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.net.VpnService;
import android.os.Bundle;
import android.support.annotation.NonNull;
@ -250,7 +249,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
switchFragment(new DNSTestFragment());
break;
case R.id.nav_github:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus")));
Daedalus.openUri("https://github.com/iTXTech/Daedalus");
break;
case R.id.nav_home:
switchFragment(new HomeFragment());

View File

@ -1,7 +1,5 @@
package org.itxtech.daedalus.fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.*;
@ -104,7 +102,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
findPreference("settings_check_update").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/releases")));
Daedalus.openUri("https://github.com/iTXTech/Daedalus/releases");
return false;
}
});
@ -112,7 +110,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
findPreference("settings_issue_tracker").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/issues")));
Daedalus.openUri("https://github.com/iTXTech/Daedalus/issues");
return false;
}
});
@ -120,7 +118,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
findPreference("settings_manual").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/wiki")));
Daedalus.openUri("https://github.com/iTXTech/Daedalus/wiki");
return false;
}
});