Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
Calendar calendar = Calendar.getInstance();
/*calendar.get(Calendar.DAY_OF_YEAR)
SimpleDateFormat dateFormat = new SimpleDateFormat("KK:mm:ss a");
String oldTime = "12:00:01 PM";
String oldTime1 = "12:20:20 PM";*/

String _day=_objapi.getday(ctx);
String _today=String.valueOf(calendar.get(Calendar.DAY_OF_YEAR));
String _isread=_objapi.getIsRead(ctx);
if("0".equals(_day))
{
_objapi.saveday(_today, ctx);
_objapi.saveIsRead("0", ctx);
}

if("0".equals(_isread))
{
if(!_today.equals(_day))
{

mNotificationManager = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notifyDetails = new Notification(R.drawable.logo,"SMS Block",System.currentTimeMillis());
Intent notificationIntent = new Intent(ctx,MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
notifyDetails.setLatestEventInfo(ctx, "SMS Block", "Click on me to view SMS Log", contentIntent);
notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
_objapi.saveIsRead("1", ctx);

}

}


----------------

package com.hukamnama.net;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class API {
private static final String APP_SHARED_PREFS = "com.hukamnama.net"; // Name of the file -.xml
private SharedPreferences appSharedPrefs;
private Editor prefsEditor;

//################--get session user ID--###########################
public String getday(Context Activityctx) {
this.appSharedPrefs = Activityctx.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
this.prefsEditor = appSharedPrefs.edit();
return appSharedPrefs.getString("_day", "0");
}
public String getIsRead(Context Activityctx) {
this.appSharedPrefs = Activityctx.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
this.prefsEditor = appSharedPrefs.edit();
return appSharedPrefs.getString("_IsRead", "0");
}


//################--save session ID--###########################
public void saveday(String _day,Context Activityctx) {
this.appSharedPrefs = Activityctx.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
this.prefsEditor = appSharedPrefs.edit();
prefsEditor.putString("_day", _day);
prefsEditor.commit();
}
public void saveIsRead(String _IsRead,Context Activityctx) {
this.appSharedPrefs = Activityctx.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
this.prefsEditor = appSharedPrefs.edit();
prefsEditor.putString("_IsRead", _IsRead);
prefsEditor.commit();
}

}
Posted
Comments
ridoy 29-Aug-12 7:39am    
where is your question?what is your problem?!
Richard MacCutchan 29-Aug-12 8:06am    
This should be reported as 'not a question'.
[no name] 29-Aug-12 9:32am    
Just an unformatted code dump.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900