CameraBrowser: Catch ActivityNotFoundException when attempting to display imported file.
Change-Id: I448f2506caf0a5599c885654fd0078beb6240965 Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -41,5 +41,6 @@
|
||||
<string name="save_failed_message">Could not save object</string>
|
||||
<string name="object_deleted_message">Object deleted</string>
|
||||
<string name="delete_failed_message">Could not delete object</string>
|
||||
<string name="start_activity_failed_message">Import succeeded, but could not display object</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.camerabrowser;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@@ -155,7 +156,11 @@ public class ObjectViewer extends Activity implements View.OnClickListener {
|
||||
if (resultUri != null) {
|
||||
Toast.makeText(this, R.string.object_saved_message, Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, resultUri);
|
||||
startActivity(intent);
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.start_activity_failed_message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.save_failed_message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user