2

Android provides the ability of setting a lockscreen messages like this one and I wanted to know how is it possible to do this through an application.

I've found and read this topic, and I tried the method

Settings.System.putString(context.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED, "Test");

but it didn't worked : the compilation failed on the "context" object.

Could someone help me please ?

EDIT: I have found the java file in the android git repositories for the owner info settings. Unfortunately, I can not exploit this data. It would be good if someone could help me. Thanks

Community
  • 1
  • 1
24PaH
  • 23
  • 4

2 Answers2

0
//Generate Notification
public void sendNotifaction(String messagebody){

    Intent intent = new Intent(this,HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

;

    //to generate more notification
    Random random = new Random();

    notifactionCode = random.nextInt(9999 - 1000) + 1000;

    PendingIntent pendingIntent = PendingIntent.getActivity(this,notifactionCode,intent,PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultRingtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationCompat = new NotificationCompat.Builder(this)
            .setWhen(System.currentTimeMillis())
            .setAutoCancel(true)
            .setSmallIcon(R.mipmap.logo)
            .setContentTitle("VIS")
            .setSound(defaultRingtone)
            .setContentIntent(pendingIntent)
            .setVibrate(new long[] {1000,1000})
            .setContentText(messagebody);


    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    notificationManager.notify(notifactionCode,notificationCompat.build());


}

May be you want this and it help you or see WAKE_CLOCK topic also.

Hitesh Danidhariya
  • 709
  • 1
  • 7
  • 14
0

Generating a notification would be the easiest way to display a message on the lockscreen but I understand that it's not what you want to do.

Unfortunately I don't think you can display a message directly on the lockscreen from an application because the potential for abuse would be too great.

Imagine having promotional messages displayed by shifty apps! That's why notifications are dismiss-able

kira_codes
  • 1,457
  • 13
  • 38
  • Thank you for your answer. I did not noticed that. Thus I think that my project is not realisable :/. It does not really matter. Thanks one more time. – 24PaH Feb 08 '17 at 22:01