General: Howto change Android core API classes?

非 Y 不嫁゛ 提交于 2019-12-12 18:33:04

问题


This is just a general question for my information. I know how to create standard Android apps, but I was wondering: How is it possible/how do people enhance Android core functions and dig deeper into the system?

For example: Let's assume I want to adapt the DownloadManager class, which is used by many apps. So, for example, one can adapt the class so that the download-text, which is displayed in the Notification bar under the download progress, is somehow changed.

Excuse me the following stupid questions, but I have no idea of these advanced topics, that's why I'm asking here ;-)

  • It is possible to change (for example) the DownloadManager class, so that it has extended functionality which will then be used by 3rd party apps, right?
  • Can the patched class then be put in the Play Store for other people to download/extend their DownloadManager functionality?
  • Will people need Root to be able to install such a change?
  • At most important: How can someone alter an Android API class? I'm really a noob here: I don't know where to get the source-code from, how to replace the standard with the enhanced class, what's needed for that, etc. Is there even a tutorial on advanced topics like this?

Please enlighten me a little bit :-)


回答1:


is possible to change (for example) the DownloadManager class, so that it has extended functionality which will then be used by 3rd party apps.

Yes, of course, Android source code is opened under Apache license, you can modify this source code, and public into the world. For some detail about DownloadManager class and many other class, in Android OS Structure, those class is programmed on upper layer, often totally in Java.

Can the patched class then be put in the Play Store for other people to download/extend their DownloadManager functionality?

I don't understand your question so much. In Play Store (and another android app store), people upload their application (in funny sentence, upload the source code has been compiled), so how can you upload a source code for user extends their apps ?

You can public your source code to github, or another place that programmers often meet, so they can view your source code, and often give you valuable ideas and comments :)

Will people need Root to be able to install such a change?

if advanced user, they can install new Android OS for their device. But I think, this answer is further than you really need.

Where to get the source-code from, how to replace the standard with the enhanced class, what's needed for that, etc. Is there even a tutorial on advanced topics like this?

In Android SDK folder, there is a folder named "Source", you can go there and see many Android source code. You can take that, read, and modify what you want. some part of Android is not here, you should google for this, it easy to find on internet.

But you should remember, when you modified this class or that class, it not belong to Android OS again, you must import this class file to your project as normal class.

So, if you want to modify base Android APIs : those APIs often write all in Java, and you read them and understand carefully, modified some part if you want, and import this class into your project.

And last word, why you should do that :) Because you can extends the class you want, and put some additional features for this class. It's easier and nicer.

Hope this help :)



来源:https://stackoverflow.com/questions/13876810/general-howto-change-android-core-api-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!