Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

resources - Setting an Android Notification Icon to a remote URL

I want to use a remote URL (like a favicon) for a notification icon, however the constructor for a notification accepts only a resource ID (which is an integer) instead of something more useful like a FileInputStream.

How can I either

  • define a new resource for a stream source

  • download an icon, add to my resources, and then dynamically get an ID?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't do this in Android currently, because resources can only be loaded from the /res/ directory of your APK. See Resources and Internationalization. The /res/ directory is built when you create your APK and can't be changed after.

Do you expect your Icon to change often enough that you need to query a URL to ensure it is up to date every time you send a notification?

Most applications that need to change their icon would simply put an update out on the Android market.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...