Quantcast
Channel: User raptortech97 - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 22

Answer by raptortech97 for Setting up notifications for Android

$
0
0

I don't know much about Android, so I can't answer that specific question, but there's still some things to change.

 @Overridepublic IBinder onBind(Intent arg0){    // TODO Auto-generated method stub    return null;}@Overridepublic void onCreate(){    // TODO Auto-generated method stub    super.onCreate();}@Overridepublic void onDestroy(){    // TODO Auto-generated method stub    super.onDestroy();}

It looks like your IDE generated these for you, but you don't need them. Get rid of them, they're just clutter.

PendingIntent pendingNotificationIntent = PendingIntent.getActivity( this.getApplicationContext(),0, intent1,PendingIntent.FLAG_UPDATE_CURRENT);

Ouch! In Java, we put one space after each comma in the argument list, and sometimes spaces in expressions. This line should look like

PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);

Also, if you put spaces around an operator, it should be one space on each side, so Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_CLEAR_TOP should be Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP

notification.setLatestEventInfo(this.getApplicationContext(), "Score Collection!", "Please enter scores at this time!", pendingNotificationIntent);

If I recall correctly, on Android all user-facing strings should be handled by the OS so that you can localize them easily.

Other than that, this code looks pretty good.


Viewing all articles
Browse latest Browse all 22

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>