Java Code Examples for android.app.Activity

The following are top voted examples for showing how to use android.app.Activity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OSchina_resources_android   File: CaptureActivityHandler.java   View source code 8 votes vote down vote up
@Override
public void handleMessage(Message message) {
    switch (message.what) {
        case R.id.restart_preview:
            restartPreviewAndDecode();
            break;
        case R.id.decode_succeeded:
            state = State.SUCCESS;
            Bundle bundle = message.getData();

            activity.handleDecode((Result) message.obj, bundle);
            break;
        case R.id.decode_failed:
            // We're decoding as fast as possible, so when one decode fails,
            // start another.
            state = State.PREVIEW;
            cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
            break;
        case R.id.return_scan_result:
            activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
            activity.finish();
            break;
    }
}
 
Example 2
Project: airgram   File: DialogsActivity.java   View source code 8 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons() {
    Activity activity = getParentActivity();
    if (activity == null) {
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    if (activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
        permissons.add(Manifest.permission.READ_CONTACTS);
        permissons.add(Manifest.permission.WRITE_CONTACTS);
        permissons.add(Manifest.permission.GET_ACCOUNTS);
    }
    if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        permissons.add(Manifest.permission.READ_EXTERNAL_STORAGE);
        permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
    String[] items = permissons.toArray(new String[permissons.size()]);
    activity.requestPermissions(items, 1);
}
 
Example 3
Project: Habitizer   File: AddHabitActivity.java   View source code 6 votes vote down vote up
/**
 * Sets up view for showing completed days
 * @param ctx
 */
public static void setUpDays(Activity ctx) {
    LinearLayout daysOuter = (LinearLayout) ctx.findViewById(R.id.days_outer);
    View childdays = ctx.getLayoutInflater().inflate(R.layout.days, null);

    // Setting things

    for (int i = 0; i < 7; i++) {
        final TextView dayTextView = (TextView) childdays.findViewById(AddHabitActivity.daytags[i]);
        final int currenti = i;
        if (AddHabitActivity.days[i] == 1) {
            dayTextView.setBackground(ctx.getDrawable(R.drawable.days_border_valid));
        }

    }

    LinearLayout daysInner = (LinearLayout) childdays.findViewById(R.id.days_inner);
    daysInner.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    daysOuter.addView(childdays);

}
 
Example 4
Project: TPlayer   File: TDevice.java   View source code 6 votes vote down vote up
/**
 * 调用系统安装了的应用分享
 *
 * @param context
 * @param title
 * @param url
 */
public static void showSystemShareOption(Activity context,
                                         final String title, final String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享:" + title);
    intent.putExtra(Intent.EXTRA_TEXT, title + " " + url);
    context.startActivity(Intent.createChooser(intent, "选择分享"));
}
 
Example 5
Project: android-dev-challenge   File: SettingsFragment.java   View source code 6 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
Example 6
Project: aos-Video   File: BrowserByExtStorage.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if(requestCode==READ_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {

            //Set directory as default in preferences
            Uri treeUri = intent.getData();
            //grant write permissions
            getActivity().getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            mCurrentDirectory = treeUri;
            listFiles(false);
            getLoaderManager().restartLoader(0, null, this);

        } else displayFailPage();
    }
}
 
Example 7
Project: cardinalsSample   File: GetPictureActivity.java   View source code 6 votes vote down vote up
/**
 * 获取图片成功后进行处理
 *
 * @param imagePath 图片路径
 */
private void resultImage(String imagePath) {
    Bitmap bitmap;
    if (!TextUtils.isEmpty(imagePath)) {
        bitmap = ImageUtil.getImageThumbnail(imagePath, IMAGE_MAX_SIZE, IMAGE_MAX_SIZE);
        String filePath = new File(SDUtil.getFileDir(), "temp2.jpg").getAbsolutePath();

        ImageUtil.saveImage(bitmap, filePath, 50);
        // deleteTempPicture();
        Logger.d("处理图片" + filePath);

        Intent resultIntent = new Intent();
        resultIntent.putExtra(IMAGE_PATH, filePath);
        setResult(Activity.RESULT_OK, resultIntent);
        GetPictureActivity.this.finish();

    } else {
        //没有获取到文件的路径
        ToastUtil.showShort("图片获取失败");

        setResult(Activity.RESULT_CANCELED);
        finish();
    }
}
 
Example 8
Project: MapDemo   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public void onJumpToNavigator() {
	/*
	 * 设置途径点以及resetEndNode会回调该接口
	 */

	for (Activity ac : activityList) {

		if (ac.getClass().getName().endsWith("BNDemoGuideActivity")) {

			return;
		}
	}
	Intent intent = new Intent(MainActivity.this,
			BNDemoGuideActivity.class);
	Bundle bundle = new Bundle();
	bundle.putSerializable(ROUTE_PLAN_NODE, mBNRoutePlanNode);
	intent.putExtras(bundle);
	startActivity(intent);

}
 
Example 9
Project: GitHub   File: PresenterManager.java   View source code 6 votes vote down vote up
@Override public void onActivityDestroyed(Activity activity) {
  if (!activity.isChangingConfigurations()) {
    // Activity will be destroyed permanently, so reset the cache
    String activityId = activityIdMap.get(activity);
    if (activityId != null) {
      ActivityScopedCache scopedCache = activityScopedCacheMap.get(activityId);
      if (scopedCache != null) {
        scopedCache.clear();
        activityScopedCacheMap.remove(activityId);
      }

      // No Activity Scoped cache available, so unregister
      if (activityScopedCacheMap.isEmpty()) {
        // All Mosby related activities are destroyed, so we can remove the activity lifecylce listener
        activity.getApplication()
            .unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks);
        if (DEBUG) {
          Log.d(DEBUG_TAG, "Unregistering ActivityLifecycleCallbacks");
        }
      }
    }
  }
  activityIdMap.remove(activity);
}
 
Example 10
Project: Camera-Roll-Android-App   File: StorageUtil.java   View source code 6 votes vote down vote up
public static StorageRoot[] loadRoots(Activity context) {
    ArrayList<StorageRoot> temp = new ArrayList<>();

    StorageRoot externalStorage = new StorageRoot(
            Environment.getExternalStorageDirectory().getPath());
    externalStorage.setName(context.getString(R.string.storage));
    temp.add(externalStorage);

    File[] removableStorageRoots = getRemovableStorageRoots(context);
    for (int i = 0; i < removableStorageRoots.length; i++) {
        temp.add(new StorageRoot(removableStorageRoots[i].getPath()));
    }

    StorageRoot[] roots = new StorageRoot[temp.size()];
    return temp.toArray(roots);
}
 
Example 11
Project: boohee_v5.6   File: CustomSportListAdapter.java   View source code 6 votes vote down vote up
public void onClick(View v) {
    new Builder(CustomSportListAdapter.this.context).setMessage("确定要删除吗?")
            .setPositiveButton("删除", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (CustomSportListAdapter.this.data != null) {
                FoodApi.deleteCustomActivities(((CustomSport) CustomSportListAdapter.this
                        .data.get(DelListener.this.position)).id, CustomSportListAdapter
                        .this.context, new JsonCallback((Activity) CustomSportListAdapter
                        .this.context) {
                    public void onFinish() {
                        super.onFinish();
                    }

                    public void ok(JSONObject object) {
                        super.ok(object);
                        CustomSportListAdapter.this.remove(DelListener.this.position);
                        CustomSportListAdapter.this.notifyDataSetChanged();
                    }
                });
            }
        }
    }).setNegativeButton("取消", null).show();
}
 
Example 12
Project: KTalk   File: EaseChatRowFile.java   View source code 6 votes vote down vote up
@Override
protected void onBubbleClick() {
    String filePath = fileMessageBody.getLocalUrl();
    File file = new File(filePath);
    if (file.exists()) {
        // open files if it exist
        FileUtils.openFile(file, (Activity) context);
    } else {
        // download the file
        context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msg", message));
    }
    if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == ChatType.Chat) {
        try {
            EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
        } catch (HyphenateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
}
 
Example 13
Project: Gdufe-Drcom-Solution   File: MainActivity.java   View source code 5 votes vote down vote up
private void forgotPsw() {
    SharedPreferences sp = getSharedPreferences(PREFERENCES_NAME, Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear();
    editor.commit();
    ed_acc.setText("");
    ed_psw.setText("");
    Toast.makeText(MainActivity.this, "已清除缓存", Toast.LENGTH_SHORT).show();
}
 
Example 14
Project: CustomAndroidOneSheeld   File: CameraUtils.java   View source code 5 votes vote down vote up
public static void setLastCapturedImagePathFromOneSheeldFolder(String lastCapturedImagePathFromOneSheeldFolder,Activity activity) {
    sharedPreferences = activity.getSharedPreferences("camera",Context.MODE_PRIVATE);
    if (lastCapturedImagePathFromOneSheeldFolder != null) {
        File tmpImage = new File(lastCapturedImagePathFromOneSheeldFolder);
        if (tmpImage.exists()) {
            CameraUtils.lastCapturedImagePathFromOneSheeldFolder = lastCapturedImagePathFromOneSheeldFolder;
            editor = sharedPreferences.edit();
            editor.putString(sharedPreferencesKey,lastCapturedImagePathFromOneSheeldFolder);
            editor.commit();
        }
    }
}
 
Example 15
Project: SmartPermission   File: SmartPermission.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void executePermissionsRequest() {
    checkObjectsValid(mObject);
    if (mObject instanceof Activity) {
        ActivityCompat.requestPermissions((Activity) mObject, mPermissions, mRequestPermissionCode);
    } else if (mObject instanceof android.support.v4.app.Fragment) {
        ((android.support.v4.app.Fragment) mObject).requestPermissions(mPermissions, mRequestPermissionCode);
    } else if (mObject instanceof android.app.Fragment) {
        ((android.app.Fragment) mObject).requestPermissions(mPermissions, mRequestPermissionCode);
    }
}
 
Example 16
Project: SocialSdkLibrary   File: QQPlatform.java   View source code 5 votes vote down vote up
@Override
public void shareMusic(int shareTarget, Activity activity, ShareObj obj) {
    if (shareTarget == Target.SHARE_QQ_FRIENDS) {
        Bundle params = buildCommonBundle(obj.getTitle(), obj.getSummary(), obj.getTargetUrl(), shareTarget);
        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_AUDIO);
        if (!TextUtils.isEmpty(obj.getThumbImagePath()))
            params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, obj.getThumbImagePath());
        params.putString(QQShare.SHARE_TO_QQ_AUDIO_URL, obj.getMediaPath());
        mTencentApi.shareToQQ(activity, params, mIUiListenerWrap);
    } else if (shareTarget == Target.SHARE_QQ_ZONE) {
        shareWeb(shareTarget, activity, obj);
    }
}
 
Example 17
Project: silly-android   File: SillyAndroid.java   View source code 5 votes vote down vote up
/**
 * Creates a new {@link android.view.ViewTreeObserver.OnGlobalLayoutListener} that attempts to calculate the keyboard size.
 * Note that this does not guarantee that a software keyboard is present, it's just a best effort detection attempt.
 * Also note that, although it's not guaranteed to work with all keyboards in all situations, this was tested against top 20 keyboards from the store and
 * had no issues detecting the changes.
 *
 * @param with    What to subscribe with (cannot be {@code null})
 * @param context The Activity context to use (cannot be {@code null})
 * @return A new instance of the layout listener. Note that this won't do anything until you attach the returned instance to the global layout by invoking
 * {@link View#getViewTreeObserver()} and then {@link ViewTreeObserver#addOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener)} on the
 * Activity's root layout, passing in the listener instance returned from this method. You also need to manually detach the listener when done listening.
 * The best practice is to do it with the {@link Activity#onStart()} and {@link Activity#onStop()} lifecycle methods.
 */
@NonNull
public static ViewTreeObserver.OnGlobalLayoutListener listenToKeyboard(@NonNull final OnKeyboardChangeListener with, @NonNull final Activity context) {
    return new ViewTreeObserver.OnGlobalLayoutListener() {
        private boolean isKeyboardVisible;

        @Override
        public void onGlobalLayout() {
            final int statusBarHeight = UI.getStatusBarHeight(context);
            final int navigationBarHeight = UI.getNavigationBarHeight(context);

            // check the display window size for the app layout
            final Rect rect = new Rect();
            context.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);

            // screen height - (user app height + status + nav) -> if non-zero, then there is a soft keyboard
            final ViewGroup layout = SillyAndroid.getContentView(context);
            if (layout == null) {
                throw new IllegalArgumentException("Passed Activity needs to have its content view set before attaching this listener");
            }
            final int keyboardHeight = layout.getRootView().getHeight() - (statusBarHeight + navigationBarHeight + rect.height());

            if (keyboardHeight <= 0) {
                if (isKeyboardVisible) {
                    with.onKeyboardHidden();
                    isKeyboardVisible = false;
                }
            } else {
                if (!isKeyboardVisible) {
                    with.onKeyboardShown(keyboardHeight);
                    isKeyboardVisible = true;
                }
            }
        }
    };
}
 
Example 18
Project: Bigbang   File: EasyPermissions.java   View source code 5 votes vote down vote up
@TargetApi(23)
private static boolean shouldShowRequestPermissionRationale(Object object, String perm) {
    if (object instanceof Activity) {
        return ActivityCompat.shouldShowRequestPermissionRationale((Activity) object, perm);
    } else if (object instanceof Fragment) {
        return ((Fragment) object).shouldShowRequestPermissionRationale(perm);
    } else if (object instanceof android.app.Fragment) {
        return ((android.app.Fragment) object).shouldShowRequestPermissionRationale(perm);
    } else {
        return false;
    }
}
 
Example 19
Project: buildAPKsApps   File: VolumeSettingHandler.java   View source code 5 votes vote down vote up
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
	if (fromUser) {

		final AudioManager manager = (AudioManager) mActivity.getSystemService(Activity.AUDIO_SERVICE);
		final int index = (Integer) seekBar.getTag();
		final int streamType = STREAM_TYPES[index];
		
		// update view
		final TextView valueView = mValueViews[index];
		valueView.setText(progress + "/" + manager.getStreamMaxVolume(streamType));
		
		//Log.d(TAG, "onProgressChanged: index: " + index + ", value: " + progress + ", seekbar: " + seekBar);
	}
}
 
Example 20
Project: Seccy   File: MainActivity.java   View source code 5 votes vote down vote up
public void glideLoadImages(int image, ImageView[] iv)
{
    Activity activity = MainActivity.this;

    for (ImageView imgview : iv)
    {
        Glide.with(activity).load(image).into(imgview);
    }
    return;
}
 
Example 21
Project: LucaHome-MediaServer   File: CurrentWeatherViewController.java   View source code 5 votes vote down vote up
public void onCreate() {
    _logger.Debug("onCreate");

    _screenEnabled = true;

    _conditionTextView = ((Activity) _context).findViewById(R.id.weatherConditionTextView);
    _temperatureTextView = ((Activity) _context).findViewById(R.id.weatherTemperatureTextView);
    _humidityTextView = ((Activity) _context).findViewById(R.id.weatherHumidityTextView);
    _pressureTextView = ((Activity) _context).findViewById(R.id.weatherPressureTextView);
    _updatedTimeTextView = ((Activity) _context).findViewById(R.id.weatherUpdateTextView);
    _conditionImageView = ((Activity) _context).findViewById(R.id.weatherConditionImageView);
}
 
Example 22
Project: Ships   File: FragmentUtils.java   View source code 5 votes vote down vote up
public static void returnFromFragment(final Fragment fragment){
	final Activity activity=fragment.getActivity();
	if (activity!=null){
		final FragmentManager fragmentManager=activity.getFragmentManager();
		if (fragmentManager!=null) {
			fragmentManager.popBackStack();
		}
	}
}
 
Example 23
Project: android-paypal-example   File: ActionItemBadge.java   View source code 5 votes vote down vote up
public static void update(final Activity act, final MenuItem menu, IIcon icon, int badgeCount) {
    if (badgeCount == Integer.MIN_VALUE) {
        update(act, menu, new IconicsDrawable(act, icon).color(Color.WHITE).actionBar(), BadgeStyles.DARK_GREY.getStyle(), null);
    } else {
        update(act, menu, new IconicsDrawable(act, icon).color(Color.WHITE).actionBar(), BadgeStyles.DARK_GREY.getStyle(), String.valueOf(badgeCount));
    }
}
 
Example 24
Project: Hitalk   File: BlurDialogFragment.java   View source code 5 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    if (mBlurEngine != null) {
        mBlurEngine.onAttach(activity); // re attached
    }
}
 
Example 25
Project: buildAPKsApps   File: VolumeSettingHandler.java   View source code 5 votes vote down vote up
public boolean prepareDialog() {

		// local cache
		final AudioManager manager = (AudioManager) mActivity.getSystemService(Activity.AUDIO_SERVICE);
		final SeekBar[] seekBars = mSeekBars;
		final TextView[] valueViews = mValueViews;
		final int[] volumes = mVolumes;
		final int length = seekBars.length;
		final int[] streamTypes = STREAM_TYPES;
		
		for (int i=0; i<length; i++) {
			
			// get value and max value
			int volume = manager.getStreamVolume(streamTypes[i]);
			int max = manager.getStreamMaxVolume(streamTypes[i]);
			
			// update values
			final TextView valueView = valueViews[i];
			valueView.setText(volume + "/" + max);
			
			// update seekbar
			SeekBar seekBar = seekBars[i];
			seekBar.setMax(max);
			seekBar.setProgress(volume);
			
			volumes[i] = volume; // store initial volume
			
			//Log.d(TAG, "prepare: index: " + i + ", value: " + volume + ", max: " + max + ", seekbar: " + seekBar);
		}
		return true;
	}
 
Example 26
Project: Ghost-Android   File: KeyboardUtils.java   View source code 5 votes vote down vote up
/**
 * Clear focus from the current view and hide the soft keyboard.
 * @param activity the current activity
 */
public static void defocusAndHideKeyboard(@Nullable Activity activity) {
    if (activity == null) return;
    View view = activity.getCurrentFocus();
    if (view != null) {
        view.clearFocus();
        hideKeyboard(activity, view.getWindowToken());
    }
}
 
Example 27
Project: Mobike   File: CaptureActivityHandler.java   View source code 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
    if (message.what == R.id.auto_focus) {
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt getUrl bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }
    } else if (message.what == R.id.restart_preview) {
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
    } else if (message.what == R.id.decode_succeeded) {
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null :
                (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳�

        activity.handleDecode((Result) message.obj, barcode);//���ؽ��
        /***********************************************************************/
    } else if (message.what == R.id.decode_failed) {
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
    } else if (message.what == R.id.return_scan_result) {
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
    } else if (message.what == R.id.launch_product_query) {
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
    }
}
 
Example 28
Project: ulogger-android   File: Alert.java   View source code 5 votes vote down vote up
/**
 * Show dialog
 * @param context Context
 * @param title Title
 * @param layoutResource Layout resource id
 * @param iconResource Icon resource id
 * @return AlertDialog Dialog
 */
static AlertDialog showAlert(Context context, CharSequence title, int layoutResource, int iconResource) {
    @SuppressLint("InflateParams")
    View view = ((Activity) context).getLayoutInflater().inflate(layoutResource, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setView(view);
    if (iconResource > 0) {
        alertDialog.setIcon(iconResource);
    }
    alertDialog.show();
    return alertDialog;
}
 
Example 29
Project: li-android-sdk-core   File: LiBaseRestRequestTest.java   View source code 5 votes vote down vote up
public void setUpTest() throws Exception {
    // Mockito has a very convenient way to inject mocks by using the @Mock annotation. To
    // inject the mocks in the test the initMocks method needs to be called.
    MockitoAnnotations.initMocks(this);

    mContext = mock(Activity.class);
}
 
Example 30
Project: letv   File: LiveLaunchUtils.java   View source code 5 votes vote down vote up
public static void launchLiveLunbo(Context context, int launchMode, String eName, boolean isLow, String programName, String cName, String channelId, String channelNum, boolean isFull) {
    setClickForPlayPageTime();
    Intent intent = new Intent(context, BasePlayActivity.class);
    intent.putExtra(PlayConstant.PLAY_TYPE, 1);
    intent.putExtra("launchMode", launchMode);
    intent.putExtra("code", eName);
    intent.putExtra(PlayConstant.LIVE_IS_LOW, isLow);
    intent.putExtra(PlayConstant.LIVE_PROGRAM_NAME, programName);
    intent.putExtra(PlayConstant.LIVE_CHANNEL_NAME, cName);
    intent.putExtra(PlayConstant.LIVE_CHANNEL_ID, channelId);
    intent.putExtra(PlayConstant.LIVE_CHANNEL_LUNBO_NUMBER, channelNum);
    intent.putExtra(PlayConstant.LIVE_FULL_ONLY, isFull);
    intent.putExtra("from", 18);
    intent.addFlags(536870912);
    Bundle bundle = new Bundle();
    bundle.putString(PlayConstant.LIVE_LAUCH_METHOD, "launchLiveLunbo");
    bundle.putString("code", eName);
    bundle.putString(PlayConstant.LIVE_PROGRAM_NAME, programName);
    bundle.putString(PlayConstant.LIVE_CHANNEL_NAME, cName);
    bundle.putString(PlayConstant.LIVE_CHANNEL_ID, channelId);
    bundle.putString(PlayConstant.LIVE_CHANNEL_LUNBO_NUMBER, channelNum);
    bundle.putBoolean(PlayConstant.LIVE_FULL_ONLY, isFull);
    LetvApplication.getInstance().setLiveLunboBundle(bundle);
    LetvLogApiTool.createPlayLogInfo("LiveLunboVideoClickPlayStart", NetworkUtils.DELIMITER_LINE, "ename=" + eName + " programName=" + programName + " isLow=" + isLow);
    if (!(context instanceof Activity)) {
        intent.addFlags(268435456);
    }
    context.startActivity(intent);
}
 
Example 31
Project: nongbeer-mvp-android-demo   File: MapActivity.java   View source code 5 votes vote down vote up
@Override
public void goToSuccessOrderActivity(){
    Intent i = new Intent( this, SuccessOrderActivity.class );
    startActivity( i );
    setResult( Activity.RESULT_OK );
    finish();
}
 
Example 32
Project: android-lite-utils   File: NetworkUtils.java   View source code 5 votes vote down vote up
/**
 * 打开网络设置界面 WIFI/流量
 *
 * @param activity
 * @param i 0:WIFI/1:流量
 */
public void openSetting(Activity activity, int i) {
    if (i == ACTION_WIFI_SETTINGS) {
        //WIFI
        activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
    } else if (i == ACTION_DATA_ROAMING_SETTINGS) {
        //流量
        activity.startActivity(new Intent(
                android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS));
    }
}
 
Example 33
Project: Remindy   File: TapTargetSequenceUtil.java   View source code 5 votes vote down vote up
private static void doShowTapTargetSequenceFor(@NonNull final Activity activity, @NonNull final List<TapTarget> targets, @Nullable final TapTargetSequence.Listener listener) {
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            new TapTargetSequence(activity)
                    .targets(targets)
                    .listener(listener)
                    .start();
        }
    }, DELAY);
}
 
Example 34
Project: android-util2   File: ImageHelper.java   View source code 5 votes vote down vote up
/**
 * get image by zoom
 */
public void pick(String path) {
    if (mDestroied) return;

    if(path != null){
        File file = new File(path);
        if(!file.exists()){
            throw new RuntimeException("file not exit, path = " + path);
        }
        mGalleryFile = file;
    }

    final Activity activity = getActivity();

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//如果大于等于7.0使用FileProvider
        intent.putExtra(MediaStore.EXTRA_OUTPUT, getUriForFile(mGalleryFile));
        intent.addFlags(FLAG_GRANT_WRITE_URI_PERMISSION);
        intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
        activity.startActivityForResult(intent, SELECT_PIC_NOUGAT);
    } else {
        //intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mGalleryFile));
        activity.startActivityForResult(intent, IMAGE_REQUEST_CODE);
    }
}
 
Example 35
Project: aos-Video   File: DensityTweak.java   View source code 5 votes vote down vote up
public DensityTweak(Activity activity) {
    mActivity = activity;
    mPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
    mIsActualLeanbackDevice = mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);

    DensityChoices = new CharSequence[DensityChoiceIds.length];
    for (int i=0; i<DensityChoiceIds.length; i++) {
        DensityChoices[i] = mActivity.getString(DensityChoiceIds[i]);
    }
}
 
Example 36
Project: DOUSalaries   File: TestUtils.java   View source code 5 votes vote down vote up
public static void rotateOrientation(Activity activity) {
    int currentOrientation = activity.getResources().getConfiguration().orientation;

    switch (currentOrientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
            rotateToPortrait(activity);
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            rotateToLandscape(activity);
            break;
        default:
            rotateToLandscape(activity);
    }
}
 
Example 37
Project: EasyEmoji   File: ViewUtil.java   View source code 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
public static boolean isTranslucentStatus(final Activity activity) {
    //noinspection SimplifiableIfStatement
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        return (activity.getWindow().getAttributes().flags &
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0;
    }
    return false;
}
 
Example 38
Project: asaf-project   File: ProgressBarIdler.java   View source code 5 votes vote down vote up
public static void makeAllProgressBarsIdle(Instrumentation instrumentation, final Activity activity) {
    instrumentation.runOnMainSync(new Runnable() {
        public void run() {
            makeAllProgressBarsIdle(activity.findViewById(android.R.id.content).getRootView());
        }
    });
}
 
Example 39
Project: letv   File: Util.java   View source code 5 votes vote down vote up
public static void hideSoftkeyboard(Activity mActivity) {
    if (mActivity != null && mActivity.getCurrentFocus() != null) {
        InputMethodManager mInputMethodManager = (InputMethodManager) mActivity.getSystemService("input_method");
        if (mInputMethodManager != null) {
            mInputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), 2);
        }
    }
}
 
Example 40
Project: DogeCV   File: ActivityViewDisplay.java   View source code 5 votes vote down vote up
public void removeCurrentView(final Context context) {
    final Activity activity = (Activity) context;
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(main.getRootView());
        }
    });
}