當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.startService方法代碼示例

本文整理匯總了Java中android.app.Activity.startService方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.startService方法的具體用法?Java Activity.startService怎麽用?Java Activity.startService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.startService方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupLocationService

import android.app.Activity; //導入方法依賴的package包/類
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
// Must be public to use PermissionsDispatcher
public void setupLocationService() {
    final String tag="setupLocationService - ";
    if (isAdded()) {
        final Activity activity=getActivity();
        if (activity!=null){
            locationServiceConnection = new LocationServiceConnection((OwnLocationReceivedListener) this);
            Intent serviceIntent = new Intent(activity,TrackService.class);
            activity.startService(serviceIntent);
            activity.bindService(new Intent(activity,TrackService.class), locationServiceConnection, Context.BIND_AUTO_CREATE);
        } else {
            Log.e(TAG,tag+"Activity is null.");
        }
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:17,代碼來源:ShowMapFragment.java

示例2: requestPushToken

import android.app.Activity; //導入方法依賴的package包/類
void requestPushToken(Activity activity){
    if (activity!=null) {
        Intent service = new Intent(activity, RegistrationIntentService.class);
        service.putExtra(RegistrationIntentService.TOKEN, "token");
        activity.startService(service);

        IntentFilter intentFilter = new IntentFilter(RegistrationIntentService.ACTION_TOKEN);
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
        activity.registerReceiver(tokenBroadcastReceiver, intentFilter);

        //send back first
        sendBroadCast();
    }
    else{

    }
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:18,代碼來源:SplashPresenter.java

示例3: updateFavorites

import android.app.Activity; //導入方法依賴的package包/類
private void updateFavorites() {
    if (mAdapter != null) {
        Activity activity = getActivity();
        if (activity != null) {
            for (int i = 0; i < mAdapter.getItemCount(); i++) {
                if (TextUtils.isEmpty(mAdapter.getItem(i).getUrl()))
                    continue;
                if (mAdapter.getItem(i).getStatus() == 1)
                    continue;
                Intent msgIntent = new Intent(activity,
                        ManualAnimeUpdaterService.class);
                msgIntent.putExtra(Constants.ANIME_URL, mAdapter.getItem(i).getUrl());
                activity.startService(msgIntent);
            }
        }
    }
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:18,代碼來源:FavoritesFragment.java

示例4: startService

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Bind the activity to a background service and put them into foreground
 * state.
 */
private void startService() {
    Activity context = cordova.getActivity();

    if (isDisabled || isBind)
        return;

    Intent intent = new Intent(
            context, ForegroundService.class);

    try {
        context.bindService(intent,
                connection, Context.BIND_AUTO_CREATE);

        fireEvent(Event.ACTIVATE, null);

        context.startService(intent);
    } catch (Exception e) {
        fireEvent(Event.FAILURE, String.format("'%s'", e.getMessage()));
    }

    isBind = true;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:27,代碼來源:BackgroundMode.java

示例5: LoadLeDongLiSteps

import android.app.Activity; //導入方法依賴的package包/類
public static void LoadLeDongLiSteps(Activity activity, CallBack callBack) {
    if (activity != null && callBack != null) {
        resultCallBack = callBack;
        Intent intent = new Intent("cn.ledongli.ldl.ledongliservice");
        intent.putExtra(PACKAGE_NAME, activity.getPackageName());
        intent.putExtra(QUERY_STRING, "step");
        Intent wrapperedIntent = createExplicitFromImplicitIntent(activity, intent);
        if (wrapperedIntent == null) {
            resultCallBack.onFailed("樂動力不在呀,請安裝樂動力~~");
        } else if (SystemUtil.getAppVersionCode("cn.ledongli.ldl") <= 422) {
            resultCallBack.onFailed("樂動力版本過低,請更新到4.2.2以上的版本");
        } else {
            registerReciver(activity);
            activity.startService(wrapperedIntent);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:LeDongLiHelper.java

示例6: startService

import android.app.Activity; //導入方法依賴的package包/類
public static void startService(Activity context, int requestCode, String input) {
    Log.d(TAG, "startService");
    PendingIntent pendingResult = context.createPendingResult(
            requestCode, new Intent(), 0);

    Intent intent = new Intent(context, DownloadIntentService.class);
    intent.putExtra(DownloadIntentService.PENDING_RESULT_EXTRA, pendingResult);
    intent.putExtra(DownloadIntentService.ID_EXTRA_INPUT, input);

    context.startService(intent);
}
 
開發者ID:Jugendhackt,項目名稱:SocialPaka,代碼行數:12,代碼來源:DownloadIntentService.java

示例7: setupNmeaClientService

import android.app.Activity; //導入方法依賴的package包/類
private void setupNmeaClientService() {
    final String tag="setupNmeaClientService - ";
    if (isAdded()) {
        final Activity activity=getActivity();
        if (activity!=null) {
            nmeaClientServiceConnection = new NmeaClientServiceConnection((ShipReceivedListener) this);
            final Intent serviceIntent = new Intent(activity, NmeaClientService.class);
            activity.startService(serviceIntent);
            activity.bindService(new Intent(activity, NmeaClientService.class), nmeaClientServiceConnection, Context.BIND_AUTO_CREATE);
        } else {
            Log.e(TAG,tag+"Activity is null.");
        }
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:15,代碼來源:ShowMapFragment.java

示例8: requestPushToken

import android.app.Activity; //導入方法依賴的package包/類
void requestPushToken(Activity activity){
    if (activity!=null) {
        Intent service = new Intent(activity, RegistrationIntentService.class);
        service.putExtra(RegistrationIntentService.TOKEN, "token");
        activity.startService(service);

        IntentFilter intentFilter = new IntentFilter(RegistrationIntentService.ACTION_TOKEN);
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
        activity.registerReceiver(tokenBroadcastReceiver, intentFilter);

        //send back first
        sendBroatCast();
    }
}
 
開發者ID:afiqiqmal,項目名稱:My-Android-Base-Code,代碼行數:15,代碼來源:SplashPresenter.java

示例9: requestOpen

import android.app.Activity; //導入方法依賴的package包/類
static void requestOpen(Activity activity, DeviceFilter deviceFilter) {
    Intent intent = new Intent(activity, DvbService.class)
            .putExtra(DEVICE_FILTER, deviceFilter);
    activity.startService(intent);
}
 
開發者ID:martinmarinov,項目名稱:AndroidDvbDriver,代碼行數:6,代碼來源:DvbService.java

示例10: intentMergeService

import android.app.Activity; //導入方法依賴的package包/類
public static void intentMergeService(Activity activity, StickerAdapt2Result result) {
    Intent intent = new Intent(activity, MergeService.class);
    intent.putExtra(MERGE_DATA, result);
    activity.startService(intent);
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:6,代碼來源:MergeService.java


注:本文中的android.app.Activity.startService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。