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;
}
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();
}
}
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();
}
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);
}
}
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");
}
}
Aggregations