小编Mas*_*han的帖子

如何在android中使用Intent Flags?

我在意图中知道不同类型的标志但无法在我的活动中使用.任何人都可以解释我,

  • 我们怎样才能完成一项活动呢?
  • 如何在意图标志的帮助下操纵活动堆栈.

android android-intent android-activity

18
推荐指数
3
解决办法
4万
查看次数

为什么总是LocationSettingsStatusCodes.SUCCESS甚至GPS关闭

if(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {

    mGoogleApiClient = new GoogleApiClient
        .Builder(this)
        .enableAutoManage(this, 34992, this)
        .addApi(LocationServices.API)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();
    mGoogleApiClient.connect();
    locationChecker(mGoogleApiClient, this);
    }
Run Code Online (Sandbox Code Playgroud)

我想在android gps关闭时看到gps对话框.但即使gps关闭,status.getStatusCode()总是成功,我认为这是错误的.为什么?

public static void locationChecker(GoogleApiClient mGoogleApiClient, final Activity activity) {

    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(LocationRequest.PRIORITY_NO_POWER);
    //locationRequest.setInterval(864 * 1000);
    //locationRequest.setFastestInterval(864 * 1000);
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
    .addLocationRequest(locationRequest);
    builder.setAlwaysShow(true);
    PendingResult<LocationSettingsResult> result =
    LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());

    result.setResultCallback(new ResultCallback<LocationSettingsResult>() {

    @Override
    public void onResult(LocationSettingsResult result) {
        final Status status = result.getStatus();
        final LocationSettingsStates state = result.getLocationSettingsStates();
            switch (status.getStatusCode()) {
                case LocationSettingsStatusCodes.SUCCESS:
                // All …
Run Code Online (Sandbox Code Playgroud)

gps android

9
推荐指数
1
解决办法
437
查看次数

是否可以在运行时以编程方式更新Android Manifest?

我要实现的目标:

我正在创建一个应用程序,该程序可以通过编程方式更改应用程序图标和应用程序名称。

我所取得的成就:

我已经实现了这一点,因为通过在Android清单中声明活动别名,只有5个名称和图标。

我面临的问题:

如果您只有5个名字,那么很容易在清单中声明它。但是,如果您不知道该怎么办。名称,您必须以编程方式更新清单。

下面是我的代码:

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.drawerstack">

    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity-alias android:label="@string/app_name1"
            android:icon="@drawable/ic_launcher"
            android:name=".MainActivity-Red"
            android:enabled="false"
            android:targetActivity=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias android:label="@string/app_name2"
            android:icon="@drawable/ic_launcher_1"
            android:name=".MainActivity-Pink"
            android:enabled="false"
            android:targetActivity=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

        <activity-alias android:label="@string/app_name3"
            android:icon="@drawable/ic_launcher_2"
            android:name=".MainActivity-Blue"
            android:enabled="false"
            android:targetActivity=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category …
Run Code Online (Sandbox Code Playgroud)

android android-manifest

5
推荐指数
1
解决办法
2326
查看次数

如何在Android应用程序的后台播放音乐?

我希望在我的应用程序中,无论应用程序中发生什么,都可以播放音乐。我正在尝试使用Service. 这是MyService.class

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;

public class MyService extends Service implements MediaPlayer.OnPreparedListener {

    MediaPlayer mMediaPlayer = null;
    private static final String ACTION_PLAY = "com.example.action.PLAY";

    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public int onStartCommand(Intent intent, int flags, int startId) {

        if (intent.getAction().equals(ACTION_PLAY)) {
            mMediaPlayer = MediaPlayer.create(this, R.raw.theme_song);
            mMediaPlayer.setOnPreparedListener(this);
            mMediaPlayer.prepareAsync(); // prepare async to not …
Run Code Online (Sandbox Code Playgroud)

java service android background

3
推荐指数
1
解决办法
3614
查看次数

水平检查线android textview

这可能是一个简单的问题,但我无法在数小时的搜索后找到解决方案.如何TextView在下图中给出删除线效果.行长度应与文本长度相同.

在此输入图像描述

checkbox android textview android-layout

1
推荐指数
1
解决办法
474
查看次数