本文整理汇总了Java中android.os.Process.THREAD_PRIORITY_BACKGROUND属性的典型用法代码示例。如果您正苦于以下问题:Java Process.THREAD_PRIORITY_BACKGROUND属性的具体用法?Java Process.THREAD_PRIORITY_BACKGROUND怎么用?Java Process.THREAD_PRIORITY_BACKGROUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.os.Process
的用法示例。
在下文中一共展示了Process.THREAD_PRIORITY_BACKGROUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
@Override
public void onCreate() {
if (DBG) Log.d(TAG, "onCreate");
sIsScannerAlive = true;
notifyListeners();
UpnpServiceManager.getSingleton(this).lockStop();
/*
during all scan process, we need to keep UpnpService on, otherwise listing will fail.
To avoid blinking, we keep it on in the networkscanner instead of the lister
*/
// setup handler
mHandlerThread = new HandlerThread("ScanWorker", Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
Looper looper = mHandlerThread.getLooper();
mHandler = new Handler(looper, this);
mBlacklist = Blacklist.getInstance(this);
}
示例2: onCreate
@Override
public void onCreate() {
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block. We also make it
// background priority so CPU-intensive work will not disrupt our UI.
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationMap = new SparseIntArray();
// Get the HandlerThread's Looper and use it for our Handler
mServiceLooper = thread.getLooper();
//mServiceHandler = new ServiceHandler(mServiceLooper);
mServiceHandler = new ServiceHandler(mServiceLooper, this);
setPrefs(PreferenceManager.getDefaultSharedPreferences(this));
}
示例3: onCreate
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Bundle args = getArguments();
final byte[] txHash = (byte[]) args.getSerializable(KEY_TRANSACTION);
transaction = checkNotNull(wallet.getTransaction(Sha256Hash.wrap(txHash)));
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
loaderManager.initLoader(ID_DYNAMIC_FEES_LOADER, null, dynamicFeesLoaderCallbacks);
}
示例4: onCreate
/**
* Initializes the content provider when it is created.
*/
@Override
public boolean onCreate() {
HandlerThread handlerThread =
new HandlerThread("DownloadProvider handler", Process.THREAD_PRIORITY_BACKGROUND);
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
mOpenHelper = new DatabaseHelper(getContext());
// Initialize the system uid
mSystemUid = Process.SYSTEM_UID;
// Initialize the default container uid. Package name hardcoded
// for now.
ApplicationInfo appInfo = null;
try {
appInfo = getContext().getPackageManager().
getApplicationInfo("com.android.defcontainer", 0);
} catch (NameNotFoundException e) {
Log.wtf(Constants.TAG, "Could not get ApplicationInfo for com.android.defconatiner", e);
}
if (appInfo != null) {
mDefContainerUid = appInfo.uid;
}
// start the DownloadService class. don't wait for the 1st download to be issued.
// saves us by getting some initialization code in DownloadService out of the way.
Context context = getContext();
context.startService(new Intent(context, DownloadService.class));
return true;
}
示例5: onCreate
@Override
public void onCreate() {
super.onCreate();
Utils.debugLog(TAG, "Creating downloader service.");
HandlerThread thread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
serviceLooper = thread.getLooper();
serviceHandler = new ServiceHandler(serviceLooper);
localBroadcastManager = LocalBroadcastManager.getInstance(this);
}
示例6: starts
private void starts(){
stops();
workThread = new HandlerThread(
GlobalAsyncThread.class.getSimpleName(),
Process.THREAD_PRIORITY_BACKGROUND);
workThread.start();
workHandler = new Handler(workThread.getLooper());
}
示例7: onCreate
@Override
public void onCreate() {
HandlerThread thread = new HandlerThread(
"ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
serviceLooper = thread.getLooper();
serviceHandler = createServiceHandler(serviceLooper, this);
}
示例8: onCreate
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Constants.ENABLE_SWEEP_WALLET)
throw new IllegalStateException("ENABLE_SWEEP_WALLET is disabled");
setRetainInstance(true);
setHasOptionsMenu(true);
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
if (savedInstanceState != null) {
restoreInstanceState(savedInstanceState);
} else {
final Intent intent = activity.getIntent();
if (intent.hasExtra(SweepWalletActivity.INTENT_EXTRA_KEY)) {
privateKeyToSweep = (VersionedChecksummedBytes) intent
.getSerializableExtra(SweepWalletActivity.INTENT_EXTRA_KEY);
// delay until fragment is resumed
handler.post(maybeDecodeKeyRunnable);
}
}
}
示例9: onCreate
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
setHasOptionsMenu(true);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
if (savedInstanceState != null) {
restoreInstanceState(savedInstanceState);
} else {
final Intent intent = activity.getIntent();
final String action = intent.getAction();
final Uri intentUri = intent.getData();
final String scheme = intentUri != null ? intentUri.getScheme() : null;
final String mimeType = intent.getType();
if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
&& intentUri != null && "bitcoin".equals(scheme)) {
initStateFromBitcoinUri(intentUri);
} else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
&& PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
final NdefMessage ndefMessage = (NdefMessage) intent
.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST,
ndefMessage);
initStateFromPaymentRequest(mimeType, ndefMessagePayload);
} else if ((Intent.ACTION_VIEW.equals(action))
&& PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) {
final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent);
if (intentUri != null)
initStateFromIntentUri(mimeType, intentUri);
else if (paymentRequest != null)
initStateFromPaymentRequest(mimeType, paymentRequest);
else
throw new IllegalArgumentException();
} else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) {
initStateFromIntentExtras(intent.getExtras());
} else {
updateStateFrom(PaymentIntent.blank());
}
}
}
示例10: newThread
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r,
namePrefix + threadNumber.getAndIncrement(),
0);
if (t.isDaemon())
t.setDaemon(false);
if (t.getPriority() != Process.THREAD_PRIORITY_BACKGROUND)
t.setPriority(Process.THREAD_PRIORITY_BACKGROUND);
return t;
}
示例11: onCreate
@Override
public void onCreate() {
// We are using a HandlerThread and a Looper to avoid loading and closing
// concurrency
MoneroHandlerThread thread = new MoneroHandlerThread("WalletService",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
// Get the HandlerThread's Looper and use it for our Handler
final Looper serviceLooper = thread.getLooper();
mServiceHandler = new WalletService.ServiceHandler(serviceLooper);
Timber.d("Service created");
}
示例12: onCreate
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
}
示例13: DefaultExecutorSupplier
public DefaultExecutorSupplier() {
ThreadFactory backgroundPriorityThreadFactory = new PriorityThreadFactory(Process.THREAD_PRIORITY_BACKGROUND);
mNetworkExecutor = new ANExecutor(DEFAULT_MAX_NUM_THREADS, backgroundPriorityThreadFactory);
mImmediateNetworkExecutor = new ANExecutor(2, backgroundPriorityThreadFactory);
mMainThreadExecutor = new MainThreadExecutor();
}
示例14: createDbHandler
private static HandlerThread createDbHandler() {
final HandlerThread handlerThread = new HandlerThread("RealmReadThread", Process.THREAD_PRIORITY_BACKGROUND);
handlerThread.start();
return handlerThread;
}
示例15: BackgroundScheduledThreadPoolExecutor
public BackgroundScheduledThreadPoolExecutor() {
super(1, new PriorityThreadFactory(TAG, Process.THREAD_PRIORITY_BACKGROUND));
setMaximumPoolSize(1);
setKeepAliveTime(10 * 1000L, TimeUnit.MILLISECONDS);
allowCoreThreadTimeOut(true);
}