Fix android.content.ActivityNotFoundException when sending email
This commit is contained in:
1 parent
f8e51c3ff7
commit
5d0e035b35
3 files changed
+61
-19
No files matched your search
@@ -19,7 +19,6 @@ package com.hippo.ehviewer;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
@@ -31,6 +30,7 @@ import com.hippo.ehviewer.app.MaterialAlertDialog;
|
||||
import com.hippo.ehviewer.network.Network;
|
||||
import com.hippo.ehviewer.ui.AbsActivity;
|
||||
import com.hippo.ehviewer.ui.GalleryListActivity;
|
||||
import com.hippo.ehviewer.util.AppUtils;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Crash;
|
||||
import com.hippo.ehviewer.util.Secret;
|
||||
@@ -160,11 +160,9 @@ public class StartActivity extends AbsActivity {
|
||||
return true;
|
||||
}
|
||||
}).show();
|
||||
Intent i = new Intent(Intent.ACTION_SENDTO);
|
||||
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "I found a bug in EhViewer !");
|
||||
i.putExtra(Intent.EXTRA_TEXT, lastCrash + "======== Description ========\n" + et.getText().toString());
|
||||
startActivity(i);
|
||||
AppUtils.sendEmail(StartActivity.this, "ehviewersu@gmail.com",
|
||||
"I found a bug in EhViewer !",
|
||||
lastCrash + "======== Description ========\n" + et.getText().toString());
|
||||
lastCrash = null;
|
||||
break;
|
||||
case MaterialAlertDialog.NEGATIVE:
|
||||
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -67,6 +58,7 @@ import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.ehclient.EhInfo;
|
||||
import com.hippo.ehviewer.network.HttpHelper;
|
||||
import com.hippo.ehviewer.preference.ListPreference;
|
||||
import com.hippo.ehviewer.util.AppUtils;
|
||||
import com.hippo.ehviewer.util.BgThread;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.DialogUtils;
|
||||
@@ -80,6 +72,15 @@ import com.hippo.ehviewer.widget.CategoryTable;
|
||||
import com.hippo.ehviewer.widget.MaterialToast;
|
||||
import com.hippo.ehviewer.widget.SuggestionHelper;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SettingsActivity extends AbsPreferenceActivity {
|
||||
@SuppressWarnings("unused")
|
||||
private static String TAG = SettingsActivity.class.getSimpleName();
|
||||
@@ -805,10 +806,8 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
}
|
||||
|
||||
} else if (KEY_AUTHOR.equals(key)) {
|
||||
Intent i = new Intent(Intent.ACTION_SENDTO);
|
||||
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "About EhViewer");
|
||||
startActivity(i);
|
||||
AppUtils.sendEmail(getActivity(), "ehviewersu@gmail.com",
|
||||
"About EhViewer", null);
|
||||
|
||||
} else if (KEY_TWITTER.equals(key)) {
|
||||
new MaterialAlertDialog.Builder(getActivity())
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
public final class AppUtils {
|
||||
|
||||
// TODO add common error tip
|
||||
public static void sendEmail(@NonNull Activity from, @NonNull String email,
|
||||
@Nullable String subject, @Nullable String text) {
|
||||
Intent i = new Intent(Intent.ACTION_SENDTO);
|
||||
i.setData(Uri.parse("mailto:" + email));
|
||||
if (subject != null) {
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
}
|
||||
if (text != null) {
|
||||
i.putExtra(Intent.EXTRA_TEXT, text);
|
||||
}
|
||||
|
||||
try {
|
||||
from.startActivity(i);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user