当前位置: 首页>>代码示例>>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;未经允许,请勿转载。