FORUMS
Remove All Ads from XDA

[Help] Notifications & Toasts don't work

35 posts
Thanks Meter: 5
 
By BlindWanderer, Member on 21st December 2019, 06:07 AM
Post Reply Email Thread
So, I'm writing my very first module and everything works except notification/toast creation. I don't know why.

The best I've managed is ONE toast but never again. I haven't even managed a single notification. What could I be doing wrong?

What drives me crazy is that the thread runs without error. I get my XposedBridge.log()'s just fine. I even throttled the reporting to no faster than every 5 seconds.

I've tried running the following from my thread. I've tried running it on the MainLooper (WTF Google, why can't you do something like Swing?)
Code:
// INSIDE my worker thread run
Application app = AndroidAppHelper.currentApplication();
mNotifyManager = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(app);
mBuilder.setContentTitle("File Thinger")
		.setContentText("Thinging in progress")
		//.setSmallIcon(R.drawable.download)
		;
Code:
//------------
// INSIDE my worker thread reporting code

//Handler handler = new Handler(Looper.getMainLooper());
//handler.post(new Runnable() {
//	 public void run() {
		if (!TextUtils.isEmpty(message)) {
			if (toast != null) {
				toast.cancel(); //dismiss current toast if visible
				toast.setText(message);
			} else {
				toast = Toast.makeText(app, message, duration);
			}
			toast.show();
		}
//	}
//});

mBuilder.setProgress(me, mp, false);
mNotifyManager.notify(notificationId, mBuilder.build());
XposedBridge.log(cp + "% (" + mp + " / " + me + ")");
For added funzies, I'm working in NoxPlayer with Android 5.
21st December 2019, 07:24 AM |#2  
OP Member
Thanks Meter: 5
 
More
I got Toast working. I put everything in the runnable. No idea why notifications aren't working.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes