android教程之hockeyapp捕获异常示例
package com.example.testhockeyapp;
import net.hockeyapp.android.crashmanager;
import net.hockeyapp.android.crashmanagerlistener;
import net.hockeyapp.android.updatemanager;
import android.os.bundle;
import android.app.activity;
import android.view.menu;
import android.view.view;
import android.view.view.onclicklistener;
import android.widget.button;
import android.widget.toast;
public class mainactivity extends activity {
private static final string app_id = "a7ab0fe5f11edc8afbfbc842ecc38ad7";
string a = null;
@override
protected void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_main);
button button = (button) findviewbyid(r.id.button1);
button.setonclicklistener(new onclicklistener() {
@override
public void onclick(view v) {
a.charat(23);
}
});
checkforupdates();
}
@override
public boolean oncreateoptionsmenu(menu menu) {
// inflate the menu; this adds items to the action bar if it is present.
getmenuinflater().inflate(r.menu.main, menu);
return true;
}
@override
protected void onresume() {
// todo auto-generated method stub
super.onresume();
checkforcrashes();
}
private void checkforcrashes() {
crashmanager.register(this, app_id, new crashmanagerlistener() {
@override
public void oncrashessent() {
super.oncrashessent();
runonuithread(new runnable() {
@override
public void run() {
toast.maketext(getapplicationcontext(),
"crash data was sent. thanks!",
toast.length_long).show();
}
});
}
@override
public void oncrashesnotsent() {
super.oncrashesnotsent();
runonuithread(new runnable() {
@override
public void run() {
toast.maketext(
getapplicationcontext(),
"crash data failed to sent. please try again later.",
toast.length_long).show();
}
});
}
});
}
private void checkforupdates() {
// remove this for store builds!
updatemanager.register(this, app_id);
}
}
上一篇: C#实现顺序表(线性表)完整实例
下一篇: 坐长途大巴