make sure browser intent exists before you open it
for some reason, we see a lot of random crashes here do people really run devices without browsers on them?
This commit is contained in:
parent
5c4d146f0e
commit
dedf213028
|
@ -665,7 +665,6 @@ public class OrbotMainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
String requestMsg = getString(R.string.hidden_service_request, hiddenServicePortRequest);
|
String requestMsg = getString(R.string.hidden_service_request, hiddenServicePortRequest);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener)
|
builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener)
|
||||||
|
@ -750,15 +749,11 @@ public class OrbotMainActivity extends AppCompatActivity
|
||||||
else if (mBtnVPN.isChecked()||forceExternal)
|
else if (mBtnVPN.isChecked()||forceExternal)
|
||||||
{
|
{
|
||||||
//use the system browser since VPN is on
|
//use the system browser since VPN is on
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
else if (Prefs.useTransparentProxying())
|
else if (Prefs.useTransparentProxying())
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -793,9 +788,7 @@ public class OrbotMainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,14 +806,25 @@ public class OrbotMainActivity extends AppCompatActivity
|
||||||
private void startIntent (String pkg, String action, Uri data)
|
private void startIntent (String pkg, String action, Uri data)
|
||||||
{
|
{
|
||||||
Intent i;
|
Intent i;
|
||||||
PackageManager manager = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
i = manager.getLaunchIntentForPackage(pkg);
|
if (pkg != null) {
|
||||||
|
i = pm.getLaunchIntentForPackage(pkg);
|
||||||
if (i == null)
|
if (i == null)
|
||||||
throw new PackageManager.NameNotFoundException();
|
throw new PackageManager.NameNotFoundException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = new Intent();
|
||||||
|
}
|
||||||
|
|
||||||
i.setAction(action);
|
i.setAction(action);
|
||||||
i.setData(data);
|
i.setData(data);
|
||||||
|
|
||||||
|
if (i.resolveActivity(pm)!=null)
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue