您的位置:首页 > 移动开发 > Android开发

Android:状态栏Notification

2016-01-05 11:20 405 查看
public class MainActivity extends Activity {

    private EditText shorttitleText;

    private EditText titleText;

    private EditText contentText;

    

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        

        shorttitleText = (EditText) this.findViewById(R.id.shorttitle);

        titleText = (EditText) this.findViewById(R.id.title);

        contentText = (EditText) this.findViewById(R.id.content);

    }

    

    public void send(View v){

        String tickerText = shorttitleText.getText().toString();

        String title = titleText.getText().toString();

        String content = contentText.getText().toString();

        int icon = android.R.drawable.stat_notify_chat;

        Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());

        Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:194949494"));
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 10, intent, 0);

        notification.setLatestEventInfo(this, title, content, pendingIntent);

        notification.defaults = Notification.DEFAULT_SOUND;

        notification.flags = Notification.FLAG_AUTO_CANCEL;

        

        NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        manager.notify(100, notification);


    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: