当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getContentResolver方法代码示例

本文整理汇总了Java中android.app.Activity.getContentResolver方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getContentResolver方法的具体用法?Java Activity.getContentResolver怎么用?Java Activity.getContentResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getContentResolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBitmapSize

import android.app.Activity; //导入方法依赖的package包/类
public static Point getBitmapSize(Uri uri, Activity activity) {
    ContentResolver resolver = activity.getContentResolver();
    Point imageSize = getBitmapBound(resolver, uri);
    int w = imageSize.x;
    int h = imageSize.y;
    if (PhotoMetadataUtils.shouldRotate(resolver, uri)) {
        w = imageSize.y;
        h = imageSize.x;
    }
    if (h == 0) return new Point(MAX_WIDTH, MAX_WIDTH);
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    float screenWidth = (float) metrics.widthPixels;
    float screenHeight = (float) metrics.heightPixels;
    float widthScale = screenWidth / w;
    float heightScale = screenHeight / h;
    if (widthScale > heightScale) {
        return new Point((int) (w * widthScale), (int) (h * heightScale));
    }
    return new Point((int) (w * widthScale), (int) (h * heightScale));
}
 
开发者ID:GitPhoenix,项目名称:VanGogh,代码行数:22,代码来源:PhotoMetadataUtils.java

示例2: getAutoScreenBrightness

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 获取自动模式下的屏幕亮度
 * @return value:0~255
 */
public static int getAutoScreenBrightness(Activity activity) {
    float nowBrightnessValue = 0;

    //获取自动调节下的亮度范围在 0~1 之间
    ContentResolver resolver = activity.getContentResolver();
    try {
        //TODO:获取到的值与实际的亮度有差异,没有找到能够获得真正亮度值的方法,希望大佬能够告知。

        nowBrightnessValue = Settings.System.getFloat(resolver, "screen_auto_brightness_adj");
        Log.d(TAG, "getAutoScreenBrightness: " + nowBrightnessValue);
    } catch (Exception e) {
        e.printStackTrace();
    }
    //转换范围为 (0~255)
    float fValue = nowBrightnessValue * 225.0f;
    Log.d(TAG,"brightness: " + fValue);
    return (int)fValue;
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:23,代码来源:BrightnessUtils.java

示例3: onSwitched

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onSwitched(boolean switched) {

	final Activity activity = mActivity;
	final ContentResolver resolver = activity.getContentResolver();
	
	setAutobrightness(activity, resolver, switched);
	
	// update setting and view
	RangeSetting setting = (RangeSetting) mSetting;
	setting.checked = switched;
	setting.descr = switched ? activity.getString(R.string.txt_autobrightness_enabled) : null;
	
	if (!switched) {
		// refresh value
		final int value = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS, 0);
		setting.value = getPercentValue(value);
	}
	
	setting.updateView();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:22,代码来源:BrightnessSettingHandler.java

示例4: loadImgThumbnail

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 获取图片缩略图 只有Android2.1以上版本支持
 *
 * @param imgName
 * @param kind    MediaStore.Images.Thumbnails.MICRO_KIND
 * @return
 */
@SuppressWarnings("deprecation")
public static Bitmap loadImgThumbnail(Activity context, String imgName,
                                      int kind) {
    Bitmap bitmap = null;

    String[] proj = {MediaStore.Images.Media._ID,
            MediaStore.Images.Media.DISPLAY_NAME};

    Cursor cursor = context.managedQuery(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
            MediaStore.Images.Media.DISPLAY_NAME + "='" + imgName + "'",
            null, null);

    if (cursor != null && cursor.getCount() > 0 && cursor.moveToFirst()) {
        ContentResolver crThumb = context.getContentResolver();
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 1;
        bitmap = MethodsCompat.getThumbnail(crThumb, cursor.getInt(0),
                kind, options);
    }
    return bitmap;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:30,代码来源:ImageUtils.java

示例5: initContentObserver

import android.app.Activity; //导入方法依赖的package包/类
static void initContentObserver(Activity activity) {

            Uri contactsUri = ContactsContract.Contacts.CONTENT_URI;

            ContentResolver contentResolver = activity.getContentResolver();

            contentResolver.
                    registerContentObserver(
                            contactsUri,
                            true,
                            new ContactsObserver(new Handler(), activity));
        }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:13,代码来源:Launcher.java

示例6: initContentObserver

import android.app.Activity; //导入方法依赖的package包/类
static void initContentObserver(Activity activity) {

        Uri externalImagesUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
        Uri internalImagesUri = MediaStore.Images.Media.INTERNAL_CONTENT_URI;
        Uri externalVideosUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
        Uri internalVideosUri = MediaStore.Video.Media.INTERNAL_CONTENT_URI;

        ContentResolver contentResolver = activity.getContentResolver();

        contentResolver.
                registerContentObserver(
                        externalImagesUri,
                        true,
                        new MediaObserver(new Handler(), activity));

        contentResolver.
                registerContentObserver(
                        internalImagesUri,
                        true,
                        new MediaObserver(new Handler(), activity));

        contentResolver.
                registerContentObserver(
                        externalVideosUri,
                        true,
                        new MediaObserver(new Handler(), activity));

        contentResolver.
                registerContentObserver(
                        internalVideosUri,
                        true,
                        new MediaObserver(new Handler(), activity));
    }
 
开发者ID:enricocid,项目名称:Gallery-example,代码行数:34,代码来源:MediaObserver.java

示例7: Modi_WangYi_Mp3_UI_doing

import android.app.Activity; //导入方法依赖的package包/类
public static void Modi_WangYi_Mp3_UI_doing(Activity con, int requestCode, int resultCode, Intent in)
{
	if (requestCode == requestcode && resultCode == Activity.RESULT_OK)
	{
		Uri uri = in.getData();
		ContentResolver cr = con.getContentResolver();  
		try
		{
			Bitmap bmp = BitmapFactory.decodeStream(cr.openInputStream(uri));
			File[] files = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/netease/cloudmusic/Ad/").listFiles();
			if (files == null)
			{
				Toast.makeText(con, "没安装网易音乐或者是没有加载广告", Toast.LENGTH_LONG).show();
				return;
			}
			Vector<String> c=new Vector<String>();
			for (File f : files) 
			{
				if (f.isDirectory())
				{
					File[] temp_files=f.listFiles();
					if (temp_files == null) continue;
					for (File inner_f : temp_files)
					{

						if (inner_f.isFile())
							c.add(inner_f.getAbsolutePath());
					}
				}
				if (f.isFile())
					c.add(f.getAbsolutePath());
			}
			for (String s : c)
			{
				OutputStream ops=new FileOutputStream(s);
				bmp.compress(Bitmap.CompressFormat.JPEG, 100, ops);
			}


		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}  
		Toast.makeText(con, "替换完成", Toast.LENGTH_SHORT).show();
		//finish();
	}
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:49,代码来源:loveviayou.java

示例8: GetISfromIntent

import android.app.Activity; //导入方法依赖的package包/类
public static InputStream GetISfromIntent(Intent u, Activity con)
{
	ContentResolver cr = con.getContentResolver();  
	try
	{
		return cr.openInputStream(u.getData());
	}
	catch (FileNotFoundException e)
	{
		e.printStackTrace();
		return null;
	}

}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:15,代码来源:loveviayou.java

示例9: checkWriteCallLog

import android.app.Activity; //导入方法依赖的package包/类
/**
 * write or delete call log, {@link android.Manifest.permission#WRITE_CALL_LOG}
 *
 * @param activity
 * @return true if success
 */
private static boolean checkWriteCallLog(Activity activity) throws Exception {
    ContentResolver contentResolver = activity.getContentResolver();
    ContentValues content = new ContentValues();
    content.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
    content.put(CallLog.Calls.NUMBER, TAG_NUMBER);
    content.put(CallLog.Calls.DATE, 20140808);
    content.put(CallLog.Calls.NEW, "0");
    contentResolver.insert(Uri.parse("content://call_log/calls"), content);

    contentResolver.delete(Uri.parse("content://call_log/calls"), "number = ?", new
            String[]{TAG_NUMBER});

    return true;
}
 
开发者ID:jokermonn,项目名称:permissions4m,代码行数:21,代码来源:PermissionsChecker.java

示例10: getManualScreenBrightness

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 获取手动模式下的屏幕亮度
 * @return value:0~255
 */
public static int getManualScreenBrightness(Activity activity) {
    int nowBrightnessValue = 0;
    ContentResolver resolver = activity.getContentResolver();
    try {
        nowBrightnessValue = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return nowBrightnessValue;
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:15,代码来源:BrightnessUtils.java

示例11: Utils

import android.app.Activity; //导入方法依赖的package包/类
public Utils(Activity a) {
	activity = a;
	cr = a.getContentResolver();
	options = PreferenceManager.getDefaultSharedPreferences(a);
	outResolution =  Integer.parseInt(options.getString(Options.PREF_RESOLUTION, "1024"));
	outQuality = Integer.parseInt(options.getString(Options.PREF_QUALITY, "85"));
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:8,代码来源:Utils.java

示例12: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractBindServiceActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.wallet = application.getWallet();
    this.contentResolver = activity.getContentResolver();
    this.loaderManager = getLoaderManager();
    this.fragmentManager = getFragmentManager();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:13,代码来源:SendCoinsFragment.java

示例13: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.wallet = application.getWallet();
    this.resolver = activity.getContentResolver();
    this.loaderManager = getLoaderManager();
    this.devicePolicyManager = (DevicePolicyManager) application.getSystemService(Context.DEVICE_POLICY_SERVICE);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:13,代码来源:WalletTransactionsFragment.java

示例14: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = activity;
    final WalletApplication application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
    this.contentResolver = activity.getContentResolver();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:EditAddressBookEntryFragment.java

示例15: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AddressBookActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.wallet = application.getWallet();
    this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    this.contentResolver = activity.getContentResolver();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:12,代码来源:WalletAddressesFragment.java


注:本文中的android.app.Activity.getContentResolver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。