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); | ||||
| 			AlertDialog.Builder builder = new AlertDialog.Builder(this); | ||||
| 			builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) | ||||
|  | @ -750,15 +749,11 @@ public class OrbotMainActivity extends AppCompatActivity | |||
| 		else if (mBtnVPN.isChecked()||forceExternal) | ||||
| 		{ | ||||
| 			//use the system browser since VPN is on | ||||
| 			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | ||||
| 			startActivity(intent); | ||||
| 			startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 		} | ||||
| 		else if (Prefs.useTransparentProxying()) | ||||
| 		{ | ||||
| 			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | ||||
| 			startActivity(intent); | ||||
| 			startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|  | @ -793,9 +788,7 @@ public class OrbotMainActivity extends AppCompatActivity | |||
| 
 | ||||
| 				@Override | ||||
| 				public void onClick(DialogInterface dialog, int which) { | ||||
| 					Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 					intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); | ||||
| 					startActivity(intent); | ||||
| 					startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); | ||||
| 					 | ||||
| 				} | ||||
| 		    	   | ||||
|  | @ -813,14 +806,25 @@ public class OrbotMainActivity extends AppCompatActivity | |||
|     private void startIntent (String pkg, String action, Uri data) | ||||
|     { | ||||
|         Intent i; | ||||
|         PackageManager manager = getPackageManager(); | ||||
| 		PackageManager pm = getPackageManager(); | ||||
| 
 | ||||
|         try { | ||||
|             i = manager.getLaunchIntentForPackage(pkg); | ||||
| 			if (pkg != null) { | ||||
| 				i = pm.getLaunchIntentForPackage(pkg); | ||||
| 				if (i == null) | ||||
| 					throw new PackageManager.NameNotFoundException(); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				i = new Intent(); | ||||
| 			} | ||||
| 
 | ||||
|             i.setAction(action); | ||||
|             i.setData(data); | ||||
| 
 | ||||
| 			if (i.resolveActivity(pm)!=null) | ||||
| 				startActivity(i); | ||||
| 
 | ||||
|         } catch (PackageManager.NameNotFoundException e) { | ||||
| 
 | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue