Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Notification for startForeground #15

Open
hassammughal opened this issue Dec 14, 2018 · 17 comments
Open

Bad Notification for startForeground #15

hassammughal opened this issue Dec 14, 2018 · 17 comments

Comments

@hassammughal
Copy link

I am getting this isssue again and again
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 actions=2 number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

@mikrosk
Copy link
Contributor

mikrosk commented Dec 14, 2018

Thanks for the bug report. What are the steps to reproduce?

@hassammughal
Copy link
Author

hassammughal commented Dec 15, 2018 via email

@hassammughal
Copy link
Author

https://stackoverflow.com/questions/50529138/notifications-not-working-on-api-278-1-0
https://stackoverflow.com/questions/51587863/bad-notification-for-start-foreground-invalid-channel-for-service-notification
https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1

Maybe these links can help you to get to the problem. Moreover, in your MainHandler.java class, you can use this approach to fix the issue. Looking forward to hearing from you soon. Thanks

@hassammughal
Copy link
Author

Did you find any solution? I need to use UDP communication using your library for sharing of files. Is it possible? Or should I start from scratch?

@mikrosk
Copy link
Contributor

mikrosk commented Dec 17, 2018

Hi there, I plan to look at this tonight or tomorrow. Basically you can do anything you could do in a TCP/IP based network environment (incl. UDP packets), as soon as the P2P channel has been established, it's the classic sockets as you know them.

@hassammughal
Copy link
Author

hassammughal commented Dec 17, 2018 via email

@mikrosk
Copy link
Contributor

mikrosk commented Dec 18, 2018

OK, I've taken a quick look. While I can confirm that the notification really doesn't work very well (and I need to look at it), it doesn't throw any exceptions on my Nexus 5X with Android 8.1.

Can you try to compile & run latest wifon-mini? It should work out of the box with latest Android studio and Gradle plugin. I also switched it to use cpt-lite, i.e. the internet-less version of CPT.

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@mikrosk
Copy link
Contributor

mikrosk commented Dec 18, 2018

Ah OK, now I see what's the problem. Yes, it's targetSdk.

Officially, we shouldn't be using it because it has been deprecated. However the reason why we do (did) is that 22 is the last version which doesn't require dynamic permissions. At the time this feature had been more and more required, I didn't have enough time and motivation to change it to the dynamic model.

So if you insist on using targetSdk > 22, I'm afraid it's up to you to make the required changes. It's nothing complicated but as I said, my time and motivation for this project has faded away... (hence the source code release).

However I'm still able to help you and give some advice, should you accept this task.

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@mikrosk
Copy link
Contributor

mikrosk commented Dec 18, 2018

Let's go item by item :)

Yah, you are right indeed, but if we use the permissions only for selecting an item from the file chooser, then its fine. I am ok with that. The main thing that I want to achieve through your library is the automatic connection, which I think so doesn't need the dynamic permissions. But if you think, the dynamic permissions are required while creating the connection as well, then I am OK with the current implementation.

The permissions are more or less needed for system stuff (like the service invocation) and then for accessing storage and network facilities. So generally speaking, I'd recommend to pay attention to the permission problem - maybe it's enough just to ask for all permissions during the startup but perhaps you will bump into more issues when targeting sdk > 22. So all it boils down to the question whether you want your app on the play store or not. If not, my recommendation would be to keep it at 22.

And I am really grateful for your offer and I do need some guidance. As I want to perform the send and receive using UDP instead of TCP, and you perform this in your OutgoingPayload class, through sockets, so is it ok if I don't use the outgoing payload class and instead simple UDP datagram for the file?

I'm not sure if I understand -- OutgoingPayload is just a wrapper around a Serializable object which is then, well, serialized into the database and waiting to be transmitted. If you want to use UDP packets, then you don't need any of this (however it requires you to do more changes to CPT). What currently happens is this:

  • CPT "magically" connects to the other device(s)
  • that "magic" is partially influenced by the content of the database (its content is hashed into one single number and compared to the number on the other device)
  • so if the numbers are different, devices will connect, exchange new content (leaving both devices with the same content at the end) and disconnect

So if you want to use UDP packets and different payloads, you have to:

Moreover, I also want to know if you are converting the byte to an array or not? As I want to send and receive a file which will contain the piece of code (JAVA) which will be executed on another device.

Yes, everything is serialized, stored into the database and then deserialized over the network. When transmitting java code, perhaps you could implement a better (more efficient) way.

And how can I get the device name instead of the MAC address that is shown in the nearby peers' list?

If nearby doesn't supply you with the user name (previously set on the other device) then it is still not available. onNearbyPeers should definitely supply you with both the mac address and user name.

In addition to this, as I am working on a research project, so I can acknowledge your library in my research paper. However, I will require your assistance to accomplish the remote task scheduling in mobile devices connected.

That would be nice. :) You mean how to decide whether to connect to some device? In that case, see above. That loop in MainHandler.java is exactly that.

So, if you have enough time, we can set some time for a meeting on skype to discuss the tasks which I want to perform using your library and you can guide me accordingly, as you are well aware of your code whereas, I will require more time to understand it and then do it.

In addition to having a really shitty internet connectivity at home right now, I would prefer to minimise my time on this. It's totally OK to ask questions, post pull requests etc but if you are up to such big changes, it's inevitable you have to dig into the code anyway. So if anything is unclear - go ahead and ask but ideally, it should be code/project related questions.

@hassammughal
Copy link
Author

hassammughal commented Dec 18, 2018 via email

@mikrosk
Copy link
Contributor

mikrosk commented Jan 21, 2019

Hey @hassammughal, have you made any progress? :)

@hassammughal
Copy link
Author

hassammughal commented Jan 21, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants