所以我经历了对我来说很奇怪的事情。我的应用程序中有一个活动,允许用户拍照然后发送它,它自己完全正常。但是,如果我转到应用程序的另一部分并启动Web视图,然后返回到摄像头,则应用程序会在我拍照时立即终止。有没有人猜测或知道为什么会这样?我对webview如何做这样的事感到困惑。在我加载webview活动之前,它每次都能正常工作。
void SelectImage() {
try
{
Intent intent = new Intent
(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}
catch (Exception e) {
Log.d("Exception:", e.toString());
e.printStackTrace();
}
}
void TakePhoto() {
try
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
catch (Exception e) {
Log.d("Exception:", e.toString());
e.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
Log.d("Result Code:", Integer.toString(resultCode));
if(data != null)
Log.d("Data Results:", data.getDataString());
if (resultCode == RESULT_OK && data != null) {
if (requestCode == 0 || requestCode == 1) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "Photo Submission From Android");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"a@b.com"});
Uri uri = data.getData();
intent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
startActivityForResult(Intent.createChooser(intent, "Send Your Photo!"), 2);
}
}
}
catch (Exception e) { Log.d("Exception:", e.toString()); e.printStackTrace(); }
}
和Webview活动:;
public class Activity_WebView extends FragmentActivity {
static WebView m_WebView;
ProgressDialog m_ProgressDialog;
boolean m_FirstLoad = true;
String m_RequestType = null;
String m_OrderUrl = "";
String m_FacebookUrl = "https://mobile.facebook.com/";
String m_TwitterUrl = "https://mobile.twitter.com/";
private class LocalWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
try {
if (m_FirstLoad) {
m_ProgressDialog = new ProgressDialog(Activity_WebView.this);
m_ProgressDialog.setTitle("Gathering Data..");
m_ProgressDialog.setMessage("One Moment Please");
m_ProgressDialog.setCancelable(false);
m_ProgressDialog.show();
m_FirstLoad = false;
}
} catch (Exception e) {
e.printStackTrace();
Log.d("Error:", e.toString());
}
}
@Override
public void onPageFinished(WebView view, String url) {
try {
if (m_ProgressDialog.isShowing())
m_ProgressDialog.dismiss();
super.onPageFinished(view, url);
} catch (Exception e) {
e.printStackTrace();
Log.d("Error:", e.toString());
}
}
}
@Override
public void finish() {
ViewGroup view = (ViewGroup) getWindow().getDecorView();
view.removeAllViews();
super.finish();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
String tempUrl = "";
m_RequestType = getIntent().getStringExtra("requestType");
switch (m_RequestType)
{
case "menu": {
tempUrl = m_OrderUrl;
break;
}
case "facebook": {
tempUrl = m_FacebookUrl;
break;
}
case "twitter": {
tempUrl = m_TwitterUrl;
break;
}
default:
break;
}
setContentView(R.layout.activity_webview);
m_WebView = (WebView) findViewById(R.id.webView);
m_WebView.setWebViewClient(new LocalWebViewClient());
m_WebView.getSettings().setJavaScriptEnabled(true);
m_WebView.getSettings().setLoadWithOverviewMode(true);
m_WebView.getSettings().setUseWideViewPort(true);
m_WebView.getSettings().setBuiltInZoomControls(true);
m_WebView.loadUrl(tempUrl);
m_FirstLoad = true;
}
catch (Exception e) { e.printStackTrace(); Log.d("Error:", e.toString()); }
}
}
答案 0 :(得分:0)
关于记忆的一切。 Web View消耗了很多,而Camera应用程序需要相当多。您可以在模拟器上尝试使用RAM的大小。
实际上,相机意图并不特别:尝试开始评级意图 - 模式将非常相似。