Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package com.example.diak.cumo;
  2.  
  3. import android.app.Notification;
  4. import android.app.NotificationManager;
  5. import android.app.PendingIntent;
  6. import android.content.Intent;
  7. import android.support.v7.app.AppCompatActivity;
  8. import android.os.Bundle;
  9. import android.view.View;
  10. import android.widget.Button;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.  
  14. private Button btn_click;
  15.  
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_main);
  21.  
  22. btn_click = (Button) findViewById(R.id.btn_click);
  23.  
  24. btn_click.setOnClickListener(new View.OnClickListener() {
  25. @Override
  26. public void onClick(View view) {
  27. Intent intent = new Intent(MainActivity.this, Result.class);
  28.  
  29. PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this,0,intent,0);
  30.  
  31. Notification notification = new Notification.Builder(MainActivity.this)
  32. .setContentTitle("Cim")
  33. .setContentText("Szoveg")
  34. .setSmallIcon(R.mipmap.ic_launcher)
  35. .addAction(R.mipmap.ic_launcher, "GO", pendingIntent)
  36. .setContentIntent(pendingIntent)
  37. .build();
  38.  
  39. NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  40. notificationManager.notify(0,notification);
  41. }
  42. });
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement