Search in sources :

Example 56 with Context

use of android.content.Context in project enroscar by stanfy.

the class SharingHelper method createSharingData.

private SharingData createSharingData(final Intent sharingIntent) {
    final SharingData data = TextUtils.isEmpty(sharingIntent.getAction()) ? new PickData() : new SharingData();
    data.intent = sharingIntent;
    final Context context = this.context.get();
    if (context instanceof Activity) {
        data.callerInfo = ((Activity) context).getCallingActivity();
    } else {
        final String pkg = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_PACKAGE);
        final String act = sharingIntent.getStringExtra(ShareCompat.EXTRA_CALLING_ACTIVITY);
        if (!TextUtils.isEmpty(pkg) && !TextUtils.isEmpty(act)) {
            data.callerInfo = new ComponentName(pkg, act);
        }
    }
    return data;
}
Also used : Context(android.content.Context) Activity(android.app.Activity) ComponentName(android.content.ComponentName)

Example 57 with Context

use of android.content.Context in project enroscar by stanfy.

the class SharingHelper method deliverError.

private void deliverError() {
    final SharingActor actor = this.actor;
    final Context context = this.context.get();
    if (actor == null || context == null) {
        return;
    }
    actor.dispatchResolverError();
}
Also used : Context(android.content.Context)

Example 58 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class BroadcastTest method testRegisteredReceivePermissionDenied.

public void testRegisteredReceivePermissionDenied() throws Exception {
    setExpectedReceivers(new String[] { RECEIVER_RESULTS });
    registerMyReceiver(new IntentFilter(BROADCAST_REGISTERED), PERMISSION_DENIED);
    addIntermediate("after-register");
    BroadcastReceiver finish = new BroadcastReceiver() {

        public void onReceive(Context context, Intent intent) {
            gotReceive(RECEIVER_RESULTS, intent);
        }
    };
    getContext().sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REGISTERED), null, finish, null, Activity.RESULT_CANCELED, null, null);
    waitForResultOrThrow(BROADCAST_TIMEOUT);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 59 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class NetworkRecommendationProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    // Configuration needed to make mockito/dexcache work.
    final Context context = getInstrumentation().getTargetContext();
    System.setProperty("dexmaker.dexcache", context.getCacheDir().getPath());
    ClassLoader newClassLoader = getInstrumentation().getClass().getClassLoader();
    Thread.currentThread().setContextClassLoader(newClassLoader);
    MockitoAnnotations.initMocks(this);
    HandlerThread thread = new HandlerThread("NetworkRecommendationProviderTest");
    thread.start();
    mRecRequestLatch = new CountDownLatch(1);
    mScoreRequestLatch = new CountDownLatch(1);
    mHandler = new Handler(thread.getLooper());
    mRecProvider = new NetworkRecProvider(mHandler, mRecRequestLatch, mScoreRequestLatch);
    mStub = INetworkRecommendationProvider.Stub.asInterface(mRecProvider.getBinder());
    mTestNetworkKeys = new NetworkKey[2];
    mTestNetworkKeys[0] = new NetworkKey(new WifiKey("\"ssid_01\"", "00:00:00:00:00:11"));
    mTestNetworkKeys[1] = new NetworkKey(new WifiKey("\"ssid_02\"", "00:00:00:00:00:22"));
}
Also used : Context(android.content.Context) HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 60 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class DatabaseStressTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Context c = getContext();
    mDatabaseFile = c.getDatabasePath("database_test.db");
    if (mDatabaseFile.exists()) {
        mDatabaseFile.delete();
    }
    mDatabase = c.openOrCreateDatabase("database_test.db", 0, null);
    assertNotNull(mDatabase);
    mDatabase.setVersion(CURRENT_DATABASE_VERSION);
    mDatabase.execSQL("CREATE TABLE IF NOT EXISTS test (_id INTEGER PRIMARY KEY, data TEXT);");
}
Also used : Context(android.content.Context)

Aggregations

Context (android.content.Context)3233 Intent (android.content.Intent)676 View (android.view.View)400 Test (org.junit.Test)346 BroadcastReceiver (android.content.BroadcastReceiver)338 IntentFilter (android.content.IntentFilter)301 TextView (android.widget.TextView)258 Resources (android.content.res.Resources)226 PendingIntent (android.app.PendingIntent)188 PackageManager (android.content.pm.PackageManager)164 File (java.io.File)156 IOException (java.io.IOException)150 LayoutInflater (android.view.LayoutInflater)139 ImageView (android.widget.ImageView)135 Drawable (android.graphics.drawable.Drawable)128 Uri (android.net.Uri)115 RemoteException (android.os.RemoteException)102 ArrayList (java.util.ArrayList)102 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)101 Bundle (android.os.Bundle)95