当前位置: 首页>>代码示例>>Java>>正文


Java IntentFilter类代码示例

本文整理汇总了Java中android.content.IntentFilter的典型用法代码示例。如果您正苦于以下问题:Java IntentFilter类的具体用法?Java IntentFilter怎么用?Java IntentFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IntentFilter类属于android.content包,在下文中一共展示了IntentFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.content.IntentFilter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    s = new Setting();
    Language = s.getLang();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    Language = preferences.getString("l",Language);
    setLanguage(Language);
    setContentView(R.layout.activity_main);
    BottomNavigationView navigation =  findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    fm=getSupportFragmentManager();
    fm.beginTransaction().add(R.id.content,new BlankFragment()).commit();
    Intent i = new Intent(this,SocketService.class);
    bindService(i,myConnection,Context.BIND_AUTO_CREATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Log.e("Brodcast","Broadcast intent onCreate invoked");
    if(savedInstanceState == null){
    if(!registred){
        LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
                new IntentFilter("my-event"));
        Log.e("Registre","Broadcast intent  register");
        registred = true;
    }}

}
 
开发者ID:RRDL,项目名称:CRT,代码行数:27,代码来源:MainActivity.java

示例2: registerReceiver

import android.content.IntentFilter; //导入依赖的package包/类
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFace.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
开发者ID:changja88,项目名称:Android_Sunshine_Watch,代码行数:9,代码来源:MyWatchFace.java

示例3: start

import android.content.IntentFilter; //导入依赖的package包/类
public void start(Context context, List<App> appsToMonitor) {
    this.context = context;
    this.appsToMonitor = appsToMonitor;
    this.lastSeenRunningApps = new ArrayList();
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.SCREEN_OFF");
    filter.addAction("android.intent.action.SCREEN_ON");
    filter.addAction(ACTION_MONITOR_APPS);
    this.receiver = new AppMonitorReceiver();
    context.registerReceiver(this.receiver, filter);
    if (((PowerManager) context.getSystemService("power")).isScreenOn()) {
        startMonitoring();
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:15,代码来源:AppMonitor.java

示例4: startBluetoothServices

import android.content.IntentFilter; //导入依赖的package包/类
/**
 * Starts bluetooth and listens to pairing requests and bluetooth state changes
 */
public static void startBluetoothServices() {
    mReceiver = new BluetoothReceiver();
    //Register the BroadcastReceiver for multiple bluetooth actions

    //when another bluetooth device is discovered in range
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);

    //when discovering action finishes (discovering means that bluetooth searches for nearby devices)
    filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    //when bluetooth changes from on to off
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);

    //when another device requests pairing with this device
    filter.addAction(BluetoothDevice.ACTION_PAIRING_REQUEST);

    mainActivity.mainRegisterReceiver(mReceiver, filter);

    if(!started) {
        //tries to start bluetooth if it is not on
       mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if(mBluetoothAdapter!=null){
            if (!mBluetoothAdapter.isEnabled()) {
                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                mainActivity.startActivityForResult(enableBtIntent, MainActivity.BLUETOOTH_ON);
            } else {
                started = true;
            }
        }

    }
}
 
开发者ID:mcr222,项目名称:pass_the_bomb,代码行数:35,代码来源:BluetoothServices.java

示例5: onCreate

import android.content.IntentFilter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_usb);

    mStatusView = (TextView) findViewById(R.id.text_status);
    mResultView = (TextView) findViewById(R.id.text_result);

    mUsbManager = getSystemService(UsbManager.class);

    // Detach events are sent as a system-wide broadcast
    IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
    registerReceiver(mUsbReceiver, filter);

    handleIntent(getIntent());
}
 
开发者ID:androidthings,项目名称:sample-usbenum,代码行数:17,代码来源:UsbActivity.java

示例6: requestPushToken

import android.content.IntentFilter; //导入依赖的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

示例7: protectIntentFilter

import android.content.IntentFilter; //导入依赖的package包/类
public static void protectIntentFilter(IntentFilter filter) {
    if (filter != null) {
        List<String> actions = mirror.android.content.IntentFilter.mActions.get(filter);
        ListIterator<String> iterator = actions.listIterator();
        while (iterator.hasNext()) {
            String action = iterator.next();
            if (SpecialComponentList.isActionInBlackList(action)) {
                iterator.remove();
                continue;
            }
            if (SYSTEM_BROADCAST_ACTION.contains(action)) {
                continue;
            }
            String newAction = SpecialComponentList.protectAction(action);
            if (newAction != null) {
                iterator.set(newAction);
            }
        }
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:21,代码来源:SpecialComponentList.java

示例8: hasSpecializedHandlerIntents

import android.content.IntentFilter; //导入依赖的package包/类
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:CustomTabsHelper.java

示例9: hasSpecializedHandlerIntents

import android.content.IntentFilter; //导入依赖的package包/类
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e("Error", "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
开发者ID:theblixguy,项目名称:AutoScrollr,代码行数:22,代码来源:ChromePackageHelper.java

示例10: registerReceiver

import android.content.IntentFilter; //导入依赖的package包/类
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    DigitalWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
开发者ID:gmontoya2483,项目名称:GoUbiquitous,代码行数:9,代码来源:DigitalWatchFaceService.java

示例11: onStart

import android.content.IntentFilter; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onStart() {
    super.onStart();
    final IntentFilter filter = new IntentFilter();
    // Play and pause changes
    filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
    // Shuffle and repeat changes
    filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
    filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
    // Track changes
    filter.addAction(MusicPlaybackService.META_CHANGED);
    // Player prepared
    filter.addAction(MusicPlaybackService.PREPARED);
    // Update a list, probably the playlist fragment's
    filter.addAction(MusicPlaybackService.REFRESH);
    getActivity().registerReceiver(mPlaybackStatus, filter);
    // Refresh the current time
    final long next = refreshCurrentTime();
    queueNextRefresh(next);

    MusicUtils.notifyForegroundStateChanged(getActivity(), isPlaying());
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:26,代码来源:AudioPlayerFragment.java

示例12: onCreate

import android.content.IntentFilter; //导入依赖的package包/类
public void onCreate(Bundle bundle){
    super.onCreate(bundle);
    mUpdateReceiver = new BroadcastReceiver(){
        @Override
        public void onReceive(Context context, Intent intent) {
            if(intent!=null&& ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED.equals(intent.getAction())) {
                getLoaderManager().restartLoader(LOADER_ID_LAST_ADDED, null, MainFragment.this);
                Log.d(TAG, "manual reload");
            }
        }
    };

    mUpdateFilter = new IntentFilter();
    for(String scheme : UriUtils.sIndexableSchemes){
        mUpdateFilter.addDataScheme(scheme);
    }
    mUpdateFilter.addAction(ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:19,代码来源:MainFragment.java

示例13: registerReceiver

import android.content.IntentFilter; //导入依赖的package包/类
/** 注册广播接受来自keyboard的车牌号 */
    public void registerReceiver() {
//        输入车牌完成后的intent过滤器
        IntentFilter finishFilter = new IntentFilter(INPUT_LICENSE_COMPLETE);
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String license = intent.getStringExtra(INPUT_LICENSE_KEY);
                if (license != null && license.length() > 0) {
                    if (keyboardUtil != null) {
                        keyboardUtil.hideKeyboard();
                    }
                    KeyBoardPopWindow.this.dismiss();
                    mListener.setLicense(license);
                }
            }
        };
        mContext.registerReceiver(receiver, finishFilter);
    }
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:20,代码来源:KeyBoardPopWindow.java

示例14: onCreate

import android.content.IntentFilter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.btn_default).setOnClickListener(this);
    findViewById(R.id.btn_custom).setOnClickListener(this);
    findViewById(R.id.btn_demo).setOnClickListener(this);

    mLlRemoteViewsContainer = (LinearLayout) findViewById(R.id.ll_remote_views);

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    IntentFilter intentFilter = new IntentFilter(DemoActivity.ACTION_REMOTE_VIEWS);
    registerReceiver(mBroadcastReceiver, intentFilter);
}
 
开发者ID:DysaniazzZ,项目名称:ArtOfAndroid,代码行数:17,代码来源:MainActivity.java

示例15: btA2dpConnect

import android.content.IntentFilter; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@RpcMinSdk(Build.VERSION_CODES.KITKAT)
@Rpc(
    description =
            "Connects to a paired or discovered device with A2DP profile."
                    + "If a device has been discovered but not paired, this will pair it."
)
public void btA2dpConnect(String deviceAddress) throws Throwable {
    BluetoothDevice device = BluetoothAdapterSnippet.getKnownDeviceByAddress(deviceAddress);
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    mContext.registerReceiver(new PairingBroadcastReceiver(mContext), filter);
    Utils.invokeByReflection(sA2dpProfile, "connect", device);
    if (!Utils.waitUntil(
            () -> sA2dpProfile.getConnectionState(device) == BluetoothA2dp.STATE_CONNECTED,
            120)) {
        throw new BluetoothA2dpSnippetException(
                "Failed to connect to device "
                        + device.getName()
                        + "|"
                        + device.getAddress()
                        + " with A2DP profile within 2min.");
    }
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:24,代码来源:BluetoothA2dpSnippet.java


注:本文中的android.content.IntentFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。