我想制作一个可以在安装我的应用程序后更改银河手机中系统字体样式的应用程序用户可以从设置>我的设备>字体样式更改字体并从列表中选择而无需root权限。我在真实类型文件中有自己的字体样式。单击此处查看我要制作的应用程序示例。
否决投票无济于事 请回答或不要投反对票。
曼尼斯特
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="1.1" package="com.monotype.android.font.presentltroman" platformBuildVersionCode="23" platformBuildVersionName="6.0-2438415">
<uses-sdk android:minSdkVersion="7" />
<application android:label="@string/app_name" android:icon="@drawable/icon">
<provider android:name=".FontContentProvider" android:authorities="com.example.myfont" />
<support-screens android:largeScreens="true" android:xlargeScreens="true" />
</application>
</manifest>
只有一项活动
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.FileNotFoundException;
public class FontContentProvider extends ContentProvider {
private static final UriMatcher uriMatcher = new UriMatcher(-1);
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
return null;
}
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
String file_name = uri.getPath();
if (file_name == null) {
throw new FileNotFoundException();
}
if (file_name.startsWith("/")) {
file_name = file_name.substring(1);
}
AssetFileDescriptor ad = null;
try {
ad = getContext().getAssets().openFd(file_name);
} catch (Exception e) {
Log.v("CPFontTest", "cp - openAssetFile EXCEPTION");
}
return ad;
}
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
public String getType(Uri uri) {
AssetManager am = getContext().getAssets();
StringBuilder xmlfileStringBuilder = new StringBuilder();
try {
for (String s : am.list("xml")) {
xmlfileStringBuilder.append(s + "\n");
}
return xmlfileStringBuilder.toString();
} catch (Exception e) {
return null;
}
}
public Uri insert(Uri uri, ContentValues values) {
return null;
}
public boolean onCreate() {
return true;
}
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
return null;
}
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
static {
uriMatcher.addURI(".fontcontentprovider", "fonts", 1);
}
}