android-hidden-api

A library that provides access to Android hidden APIs and internal resources.

Github星跟踪图

Android Hidden API Download

Android Hidden API is a modified jar file which combines the android.jar from the Android SDK with the framework.jar from a real device. This jar enables to use Android's internal/hidden APIs in development.

What is Android internal and hidden APIs?
The internal API is located in the com.android.internal package which is available in the framework.jar file from a real Android device, while the hidden API is located in the android.jar file with @hide javadoc attribute. Although the classes & methods are public you cannot access it directly. There are pretty methods and resources you can use from this package. I will assume this is one API and I will refer to it as to hidden API. Learn more about hidden API here.

What's the advantage?
You don't need to create new classes, constants, methods or resources when you want to use the similar function in your project. For example, if you want to create a new String resource that contains the 'accept' word. Then you want to create a new translation to another language, e.g. Arabic, Indonesian, even with all languages in this world. This is too exhausting and a waste of time. Why don't you use com.android.internal.R.string.accept which is retrieved via InternalAccessor.getString("accept")?

Usage

If you plan to use only Android internal resources rather than internal classes or methods,
do:

dependencies {
    implementation 'com.anggrayudi:android-hidden-api:28.1'
}

Note: If you encounter error Failed to resolve com.anggrayudi:android-hidden-api:x.x, then add the following config:

repositories {
    maven { url 'https://dl.bintray.com/anggrayudi/maven/' }
}

Here's some example of accessing internal resources:

import com.anggrayudi.hiddenapi.Res;

    String accept = InternalAccessor.getString(Res.string.accept);
    float sbar_height = InternalAccessor.getDimension(Res.dimen.status_bar_height);
    int notif_color = InternalAccessor.getColor("config_defaultNotificationColor");

If you also want to include the internal classes or methods, do the following:

  1. Go to <SDK location>/platforms/.
  2. Copy, paste and replace the downloaded hidden API file into this directory, e.g. android-28/android.jar.
  3. Change compileSdkVersion and targetSdkVersion to 28 (for example).
  4. Finally, rebuild your project.

Note: Higher compileSdkVersion and targetSdkVersion will be better.

License

Copyright 2015-2019 Anggrayudi Hardiannicko A.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

主要指标

概览
名称与所有者anggrayudi/android-hidden-api
主编程语言Java
编程语言Java (语言数: 2)
平台
许可证Apache License 2.0
所有者活动
创建于2015-09-16 11:58:33
推送于2025-01-17 11:02:07
最后一次提交2025-01-17 18:02:03
发布数2
最新版本名称35.0 (发布于 )
第一版名称30.0 (发布于 )
用户参与
星数3.5k
关注者数131
派生数644
提交数92
已启用问题?
问题数89
打开的问题数40
拉请求数3
打开的拉请求数0
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?