Android ContextWrapper - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ContextWrapper class.

This code example shows how to use the following methods:getString, getPackageName, getResources
This code example shows how to use the following methods:getActivity, getApplicationContext, getClass
 
	private MoSyncNFCForegroundUtil(Activity activity, NfcAdapter nfc) {
	    this.activity = activity;
	    this.nfc = nfc;
 
	    intent = PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
 
	    // TODO: NDEF!? 
	    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
 
//	    try { 
//	        ndef.addDataType("*/*"); 
//	    } catch (MalformedMimeTypeException e) { 
//	        throw new RuntimeException("Unable to speciy */* Mime Type", e); 
//	    } 
 
	    intentFilters = new IntentFilter[] { ndef };
 
	    // TODO: READ FROM NFC.XML OR SMTHG 
	    techLists = new String[][] {

8
CodeRank
This code example shows how to use the following methods:getContentResolver
    private Activity activity;
    private ContentResolver contentResolver;
 
    @Before 
    public void setUp() throws Exception { 
        activity = new Activity();
        contentResolver = activity.getContentResolver();
    } 
 
    @Test 
    public void whileApplicationStaysSame_shouldRememberOldSettings() throws Exception { 
        Settings.System.putInt(contentResolver, "property", 1);
        assertThat(Settings.System.getInt(contentResolver, "property", 0)).isEqualTo(1);
 
        activity = new Activity();
        contentResolver = activity.getContentResolver();
        assertThat(Settings.System.getInt(contentResolver, "property", 0)).isEqualTo(1);
    } 
 
    @Test 
7
CodeRank
This code example shows how to use the following methods:getSystemService, getClass
This code example shows how to use the following methods:getSystemService
      @Override public void run() { 
        Application app = (Application) getTargetContext().getApplicationContext();
        String simpleName = SpoonInstrumentationTestRunner.class.getSimpleName();
 
        // Unlock the device so that the tests can input keystrokes. 
        ((KeyguardManager) app.getSystemService(KEYGUARD_SERVICE)) //
            .newKeyguardLock(simpleName) //
            .disableKeyguard();
        // Wake up the screen. 
        ((PowerManager) app.getSystemService(POWER_SERVICE)) //
            .newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, simpleName) //
            .acquire();
      } 
    }); 
 
    super.onStart(); 
  } 
} 
7
CodeRank
This code example shows how to use the following methods:deleteFile, openFileOutput, openOrCreateDatabase
		db.close();
	} 
 
	@Override 
	public void deletePlaylist(String playlistName) {
		SQLiteDatabase db = mActivity.openOrCreateDatabase(DB_NAME, Context.MODE_PRIVATE, null);
 
		String fileName = queryForFileName(playlistName, db);
		if(fileName != null)
			mActivity.deleteFile(fileName);
		//mActivity.openFileOutput(fileName, Context.MODE_PRIVATE).getFD(). 
 
		String[] whereArgs = {playlistName};
		db.delete(TABLE_PLAYLIST, "PlaylistName = ?", whereArgs);
 
		db.close();
	} 
 
	@Override 
	public ArrayList<String> getAvailablePlaylists() {

7
CodeRank
This code example shows how to use the following methods:getPackageManager
		 *   - 端末初期化後に一度もGoogle Playを開いてない状態でapkをadb installして起動した場合 
		 * 
		 *  2013/5/23 
		 */ 
		 
	    final PackageManager packageManager = this.activity.getPackageManager();
	    final Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
	    List<ResolveInfo> list = packageManager.queryIntentServices(intent, 0);
	    return list.size() > 0;
	} 
	 
	private BillingManager(Activity context) {
		Log.d(kClassName, "BillingManager");
		 
		this.activity  = context;
		this.iabHelper = new IabHelper(this.activity);
		 
		this.iabHelper.enableDebugLogging(true); // TODO : Production is false : Debug is true
		 
		if (!isBillingAvailable()) { 
			PFInterface.startAlertDialog("課金制限", "Google Playアカウントを確認してください"); 
7
CodeRank
This code example shows how to use the following methods:getPackageName
	 * Parses the deploy.json file if it exists 
	 */ 
	public TiDeployData(Application app)
	{ 
		File extStorage = Environment.getExternalStorageDirectory();
		File deployJson = new File(new File(extStorage, app.getPackageName()), "deploy.json");
 
		if (deployJson.exists()) {
			readDeployData(deployJson);
		} 
	} 
 
	protected void readDeployData(File deployJson)
	{ 
		try { 
			FileInputStream stream = new FileInputStream(deployJson);
			deployData = new JSONObject(KrollStreamHelper.toString(stream));
			Log.d(TAG, "Read deploy data: " + deployData.toString(), Log.DEBUG_MODE);
 
		} catch (FileNotFoundException e) {
7
CodeRank
This code example shows how to use the following methods:finish, getFilesDir
    } 
 
    public void testCopySampleAttachmentsToSDCARD() throws Throwable { 
        Assert.assertNotNull(mActivity);
 
        File sampleImage1 = new File(mActivity.getFilesDir()
                + "/sample_attachment_image1.jpg"); 
        Assert.assertTrue(sampleImage1.exists());
 
        File sampleImage2 = new File(mActivity.getFilesDir()
                + "/sample_attachment_image2.jpg"); 
        Assert.assertTrue(sampleImage2.exists());
 
        mActivity.finish();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getComponentName, startActivity, getPackageManager
                        true, 0, "attachment", 0, 10)) { 
            // query the package manager to see if there's a registered handler 
            //     that matches. 
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(url), mimetype);
            ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
            if (info != null) {
                ComponentName myName = activity.getComponentName();
                // If we resolved to ourselves, we don't want to attempt to 
                // load the url only to try and download it again. 
                if (!myName.getPackageName().equals(
                        info.activityInfo.packageName)
                        || !myName.getClassName().equals(
                                info.activityInfo.name)) {
                    // someone (other than us) knows how to handle this mime 
                    // type with this scheme, don't download. 
                    try { 
                        activity.startActivity(intent);
                        return; 

7
CodeRank

Related Android ContextWrapper Questions & Answers:

See Code Examples for Android ContextWrapper Methods: