Search in sources :

Example 36 with Context

use of android.content.Context in project AndroidTraining by mixi-inc.

the class ActionBarSherlockNative method getThemedContext.

@Override
protected Context getThemedContext() {
    Context context = mActivity;
    TypedValue outValue = new TypedValue();
    mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true);
    if (outValue.resourceId != 0) {
        //We are unable to test if this is the same as our current theme
        //so we just wrap it and hope that if the attribute was specified
        //then the user is intentionally specifying an alternate theme.
        context = new ContextThemeWrapper(context, outValue.resourceId);
    }
    return context;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) TypedValue(android.util.TypedValue)

Example 37 with Context

use of android.content.Context in project AndroidDynamicLoader by mmin18.

the class MyApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    try {
        Context mBase = new Smith<Context>(this, "mBase").get();
        Object mPackageInfo = new Smith<Object>(mBase, "mPackageInfo").get();
        Smith<ClassLoader> sClassLoader = new Smith<ClassLoader>(mPackageInfo, "mClassLoader");
        ClassLoader mClassLoader = sClassLoader.get();
        ORIGINAL_LOADER = mClassLoader;
        MyClassLoader cl = new MyClassLoader(mClassLoader);
        sClassLoader.set(cl);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Context(android.content.Context)

Example 38 with Context

use of android.content.Context in project qksms by moezbhatti.

the class QKSMSAppBase method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    if (Log.isLoggable(LogTag.STRICT_MODE_TAG, Log.DEBUG)) {
        // Log tag for enabling/disabling StrictMode violation log. This will dump a stack
        // in the log that shows the StrictMode violator.
        // To enable: adb shell setprop log.tag.Mms:strictmode DEBUG
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    }
    sQKSMSApp = this;
    loadDefaultPreferenceValues();
    // Initialize analytics, leakcanary, and crittercism
    AnalyticsManager.getInstance().init(this);
    refWatcher = LeakCanary.install(this);
    // Figure out the country *before* loading contacts and formatting numbers
    Country country = new Country(Locale.getDefault().getCountry(), Country.COUNTRY_SOURCE_LOCALE);
    mCountryIso = country.getCountryIso();
    Context context = getApplicationContext();
    mPduLoaderManager = new PduLoaderManager(context);
    mThumbnailManager = new ThumbnailManager(context);
    registerActivityLifecycleCallbacks(new LifecycleHandler());
    ThemeManager.init(this);
    MmsConfig.init(this);
    Contact.init(this);
    DraftCache.init(this);
    Conversation.init(this);
    DownloadManager.init(this);
    RateController.init(this);
    LayoutManager.init(this);
    NotificationManager.init(this);
    LiveViewManager.init(this);
    QKPreferences.init(this);
    activePendingMessages();
}
Also used : Context(android.content.Context) StrictMode(android.os.StrictMode) ThumbnailManager(com.moez.QKSMS.common.google.ThumbnailManager) LifecycleHandler(com.moez.QKSMS.common.LifecycleHandler) Country(android.location.Country) PduLoaderManager(com.moez.QKSMS.common.google.PduLoaderManager)

Example 39 with Context

use of android.content.Context in project qksms by moezbhatti.

the class Transaction method sendMMS.

private void sendMMS(final byte[] bytesToSend) {
    revokeWifi(true);
    // enable mms connection to mobile data
    mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    int result = beginMmsConnectivity();
    if (LOCAL_LOGV)
        Log.v(TAG, "result of connectivity: " + result + " ");
    if (result != 0) {
        // if mms feature is not already running (most likely isn't...) then register a receiver and wait for it to be active
        IntentFilter filter = new IntentFilter();
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        final BroadcastReceiver receiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context1, Intent intent) {
                String action = intent.getAction();
                if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                    return;
                }
                @SuppressWarnings("deprecation") NetworkInfo mNetworkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
                if ((mNetworkInfo == null) || (mNetworkInfo.getType() != ConnectivityManager.TYPE_MOBILE)) {
                    return;
                }
                if (!mNetworkInfo.isConnected()) {
                    return;
                } else {
                    // ready to send the message now
                    if (LOCAL_LOGV)
                        Log.v(TAG, "sending through broadcast receiver");
                    alreadySending = true;
                    sendData(bytesToSend);
                    context.unregisterReceiver(this);
                }
            }
        };
        context.registerReceiver(receiver, filter);
        try {
            Looper.prepare();
        } catch (Exception e) {
        // Already on UI thread probably
        }
        // try sending after 3 seconds anyways if for some reason the receiver doesn't work
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                if (!alreadySending) {
                    try {
                        if (LOCAL_LOGV)
                            Log.v(TAG, "sending through handler");
                        context.unregisterReceiver(receiver);
                    } catch (Exception e) {
                    }
                    sendData(bytesToSend);
                }
            }
        }, 7000);
    } else {
        // mms connection already active, so send the message
        if (LOCAL_LOGV)
            Log.v(TAG, "sending right away, already ready");
        sendData(bytesToSend);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) NetworkInfo(android.net.NetworkInfo) Handler(android.os.Handler) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) MmsException(com.google.android.mms.MmsException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 40 with Context

use of android.content.Context in project k-9 by k9mail.

the class MigrationTo43 method fixOutboxFolders.

public static void fixOutboxFolders(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
    try {
        LocalStore localStore = migrationsHelper.getLocalStore();
        Account account = migrationsHelper.getAccount();
        Context context = migrationsHelper.getContext();
        // If folder "OUTBOX" (old, v3.800 - v3.802) exists, rename it to
        // "K9MAIL_INTERNAL_OUTBOX" (new)
        LocalFolder oldOutbox = new LocalFolder(localStore, "OUTBOX");
        if (oldOutbox.exists()) {
            ContentValues cv = new ContentValues();
            cv.put("name", Account.OUTBOX);
            db.update("folders", cv, "name = ?", new String[] { "OUTBOX" });
            Timber.i("Renamed folder OUTBOX to %s", OUTBOX);
        }
        // Check if old (pre v3.800) localized outbox folder exists
        String localizedOutbox = context.getString(R.string.special_mailbox_name_outbox);
        LocalFolder obsoleteOutbox = new LocalFolder(localStore, localizedOutbox);
        if (obsoleteOutbox.exists()) {
            // Get all messages from the localized outbox ...
            List<? extends Message> messages = obsoleteOutbox.getMessages(null, false);
            if (messages.size() > 0) {
                // ... and move them to the drafts folder (we don't want to
                // surprise the user by sending potentially very old messages)
                LocalFolder drafts = new LocalFolder(localStore, account.getDraftsFolderName());
                obsoleteOutbox.moveMessages(messages, drafts);
            }
            // Now get rid of the localized outbox
            obsoleteOutbox.delete();
            obsoleteOutbox.delete(true);
        }
    } catch (Exception e) {
        Timber.e(e, "Error trying to fix the outbox folders");
    }
}
Also used : Context(android.content.Context) LocalFolder(com.fsck.k9.mailstore.LocalFolder) ContentValues(android.content.ContentValues) Account(com.fsck.k9.Account) LocalStore(com.fsck.k9.mailstore.LocalStore)

Aggregations

Context (android.content.Context)7516 Test (org.junit.Test)1645 Intent (android.content.Intent)1356 View (android.view.View)797 TextView (android.widget.TextView)549 BroadcastReceiver (android.content.BroadcastReceiver)497 IntentFilter (android.content.IntentFilter)485 PackageManager (android.content.pm.PackageManager)383 Resources (android.content.res.Resources)369 ArrayList (java.util.ArrayList)358 Bundle (android.os.Bundle)292 PendingIntent (android.app.PendingIntent)281 File (java.io.File)280 LayoutInflater (android.view.LayoutInflater)279 ImageView (android.widget.ImageView)263 Drawable (android.graphics.drawable.Drawable)256 IOException (java.io.IOException)248 Uri (android.net.Uri)247 RecyclerView (android.support.v7.widget.RecyclerView)200 Activity (android.app.Activity)198