我是初学者。每当我尝试启动我的Android应用程序时,它都会显示错误unfortunately my app has been stopped
。现在让我具体一点,我创建了一个pushbots应用程序,用于获取通知并通过将其转换为字符串在textview上显示。当通知到达时它会完美地工作,当我点击通知时它会在屏幕上显示字符串,但是当我启动它时不会。我问了一个问题,因为deadfish说它可能会因为我的bundle是null而发生,所以我尽我所能为textview提供一个临时字符串,我正在显示字符串。但它仍然显示错误。我将在启动应用程序时向您显示logcat。我认为null bundle不是问题
08-16 08:58:06.868 13447-13454/com.bluestacks.chartapp I/jdwp﹕ Ignoring second debugger -- accepting and dropping
公共类MainActivity扩展了ActionBarActivity {
public static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Pushbots.sharedInstance().init(this);
Intent intent = getIntent();
//log the message in JSON format
Log.i(TAG, "Received message >> " + intent.getExtras().toString());
//Retrieve message and extra
String message = intent.getExtras().getString("message");
TextView t1 = (TextView)findViewById(R.id.textView);
if(message!=null) {
t1.setText(message);
}
else
{
t1.setText("null");
}
Bundle extras = intent.getExtras();
String bigText = null;
TextView t2 = (TextView) findViewById(R.id.textView2);
if (extras != null && extras.containsKey("bigText")) {
bigText = extras.getString("bigText");
t2.setText(bigText);
}
else{
t2.setText("null");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}