У меня есть настраиваемая панель действий и привязка к ней, которая работает в фоновом режиме, по какой-то странной причине моя сила приложения закрывается. Я делаю работу сети в doinbackground
Attached Ниже приведен кодПользовательская панель действий onclick не работает для задачи async - android
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.enroll);
final ActionBar mActionBar = getActionBar();
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
LayoutInflater mInflater = LayoutInflater.from(enroll.this);
final View mCustomView = mInflater.inflate(R.layout.custom_actionbar_enroll, null);
TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text1);
mTitleTextView.setText("True Tracer");
String fontPath = "fonts/stasmic_.ttf";
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
mTitleTextView.setTypeface(tf);
final ImageButton imageButton = (ImageButton) mCustomView
.findViewById(R.id.imageButton1);
mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(true);
tpass=(TextView)findViewById(R.id.tip);
otp1=(EditText)findViewById(R.id.otp1);
pref = getApplicationContext().getSharedPreferences("MyPref", 0);
String samp=pref.getString("mynumber", null);
tpass.setText("Self authentication SMS sent \n with activation code to "+samp);
imageButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
backend runner = new backend();
runner.execute();
}
});
}
class backend extends AsyncTask<String, Void, Result>
{
@Override
protected Result doInBackground(String... params) {
do something();
}
}
Опубликовать ошибки в logcat –
Вы упомянули разрешение сети в файле манифеста? – Ahmed
Я запустил его на своем мобильном телефоне. Не уверен, как получить logcat –