通知后应用程序崩溃

时间:2014-04-24 10:56:37

标签: android android-notifications

*通知工作正常,但问题是点击按钮后崩溃了 *它说n添加@添加@ SuppressWarnings'deprication'          和          将@ SuppressWarnings'deprication'添加到onclick

public class testInput extends Activity {

    Button Setbutton;
    Location location, locationA, locationB;
    LocationManager locationManager;
    NotificationManager nm;
    public static final int uniqueId =1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.showcoords);

        nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(uniqueId);

        Setbutton = (Button) findViewById(R.id.btnShowLocation);

        Setbutton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(testInput.this, goIn.class);
                PendingIntent pi = PendingIntent.getActivity(getBaseContext(),
                        0, intent, 0);
                String body = "This is a Notification";
                String title = "Test";
                Notification n = new Notification(R.drawable.route, body,
                        System.currentTimeMillis());
                n.setLatestEventInfo(testInput.this, title, body, pi);
                n.defaults = Notification.DEFAULT_ALL;
                nm.notify(uniqueId, n);
                finish();
            }
        });
    }

}

0 个答案:

没有答案