我在我的应用中使用{{1}}。我只想在我的应用程序崩溃时向用户显示对话框。
这是我目前的代码:
{{1}}
答案 0 :(得分:1)
完全正常运行的演示
申请类
@ReportsCrashes(formUri = "http://yourserver.com/yourscript",
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.app_name,
resDialogText = R.string.app_name,
resDialogIcon = android.R.drawable.ic_dialog_info,
resDialogTitle = R.string.app_name,
resDialogCommentPrompt = R.string.app_name,
resDialogEmailPrompt = R.string.app_name,
resDialogOkToast = R.string.app_name,
resDialogTheme = R.style.AppTheme_Dialog)
public class App extends Application {
private Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
ACRA.init(this);
}
}
<强> MainActivity 强>
public class MainActivity extends AppCompatActivity {
Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
EditText number = (EditText) findViewById(R.id.foodName);
number.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int a = 0 / 0;
}
});
}
}
<强> activity_main.xml中强>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/base"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@color/white"
android:orientation="horizontal"
android:weightSum="10">
<EditText
android:id="@+id/foodName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="64dp"
android:layout_marginRight="64dp"
android:hint="Food name"
android:inputType="textCapWords"
android:textColor="@color/colorPrimaryDark"
android:textColorHint="@color/colorPrimaryDark"
android:textSize="32sp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
对话框: