本文整理匯總了Java中android.content.res.Resources.getAssets方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getAssets方法的具體用法?Java Resources.getAssets怎麽用?Java Resources.getAssets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getAssets方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRoundIcon
import android.content.res.Resources; //導入方法依賴的package包/類
private Drawable getRoundIcon(Context context,String packageName, int iconDpi) {
mPackageManager = context.getPackageManager();
try {
Resources resourcesForApplication = mPackageManager.getResourcesForApplication(packageName);
AssetManager assets = resourcesForApplication.getAssets();
XmlResourceParser parseXml = assets.openXmlResourceParser("AndroidManifest.xml");
int eventType;
while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT)
if (eventType == XmlPullParser.START_TAG && parseXml.getName().equals("application"))
for (int i = 0; i < parseXml.getAttributeCount(); i++)
if (parseXml.getAttributeName(i).equals("roundIcon"))
return resourcesForApplication.getDrawableForDensity(Integer.parseInt(parseXml.getAttributeValue(i).substring(1)), iconDpi, context.getTheme());
parseXml.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例2: say
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* get String out of a string-value file
*
* @param resourceId id of string
* @param useTTSLanguage set to true if the string should be said in the current language of the tts engine
*
* */
public Future say(Integer resourceId, Boolean useTTSLanguage) {
if(useTTSLanguage) {
Resources standardResources = session.getContext().getResources();
AssetManager assets = standardResources.getAssets();
DisplayMetrics metrics = standardResources.getDisplayMetrics();
Configuration config = new Configuration(standardResources.getConfiguration());
try {
config.locale = LANGUAGE_TO_LOCALE.get((String) this.getLanguage().get());
Resources defaultResources = new Resources(assets, metrics, config);
String text = defaultResources.getString(resourceId);
return this.say(text);
} catch (ExecutionException e) {
Log.d("PepperAndroid.Say", e.getMessage());
}
}
// Fallback to default language
return this.say(this.session.getContext().getResources().getString(resourceId));
}
示例3: getAssetPathFromResources
import android.content.res.Resources; //導入方法依賴的package包/類
private List<String> getAssetPathFromResources(Resources resource){
List<String> paths = null;
try{
AssetManager asset = resource.getAssets();
paths = DelegateResources.getCurrentAssetPath(asset);
} catch(Exception e){
e.printStackTrace();
}
return paths;
}
示例4: SaiyResources
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Constructor
*
* @param mContext the application context
* @param sl the {@link SupportedLanguage}
*/
public SaiyResources(@NonNull final Context mContext, @NonNull final SupportedLanguage sl) {
this.mContext = mContext;
final Resources resources = this.mContext.getResources();
this.assetManager = resources.getAssets();
this.metrics = resources.getDisplayMetrics();
this.configuration = new Configuration(resources.getConfiguration());
this.targetLocale = sl.getLocale();
}
示例5: BaseResources
import android.content.res.Resources; //導入方法依賴的package包/類
public BaseResources(Resources baseResources) {
this(baseResources.getAssets(), baseResources.getDisplayMetrics(), baseResources.getConfiguration());
}
示例6: ResourcesOverride
import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressWarnings("deprecated")
ResourcesOverride(Resources parent, int overrideId, String overrideValue) {
super(parent.getAssets(), parent.getDisplayMetrics(), parent.getConfiguration());
mOverrideId = overrideId;
mOverrideValue = overrideValue;
}
示例7: LeanplumResources
import android.content.res.Resources; //導入方法依賴的package包/類
public LeanplumResources(Resources base) {
super(base.getAssets(), base.getDisplayMetrics(), base.getConfiguration());
}
示例8: TintResources
import android.content.res.Resources; //導入方法依賴的package包/類
public TintResources(@NonNull Context context, @NonNull Resources res) {
super(res.getAssets(), res.getDisplayMetrics(), res.getConfiguration());
this.mContextRef = new WeakReference(context);
}