GVKun编程网logo

输入最大长度在Android -Ionic上不起作用(输入文本最大长度)

23

针对输入最大长度在Android-Ionic上不起作用和输入文本最大长度这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展ACCESS_COARSE_LOCATION在Android6上不起作

针对输入最大长度在Android -Ionic上不起作用输入文本最大长度这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展ACCESS_COARSE_LOCATION在Android 6上不起作用、android – FCM通知click_action不起作用、android – iframe标签在最新版本的Ionic中不起作用、android – Style在Button上不起作用等相关知识,希望可以帮助到你。

本文目录一览:

输入最大长度在Android -Ionic上不起作用(输入文本最大长度)

输入最大长度在Android -Ionic上不起作用(输入文本最大长度)

我有一个输入字段,并且我还需要阻止用户输入超出允许字符的范围。

<input type="text" name="callsign" maxlength="7" >

它可以在浏览器中工作,但不能在android设备上工作吗?

答案1

小编典典

感谢您的所有答复。您的答复并没有给我提供适当的解决方案。然后我为此创建了一条指令。

指令

myApp.directive(''limitChar'', function() {    ''use strict'';    return {        restrict: ''A'',        scope: {            limit: ''=limit'',            ngModel: ''=ngModel''        },        link: function(scope) {            scope.$watch(''ngModel'', function(newValue, oldValue) {                if (newValue) {                    var length = newValue.toString().length;                    if (length > scope.limit) {                        scope.ngModel = oldValue;                    }                }            });        }    };})

html

<input type="text" limit-char limit="7" >

ACCESS_COARSE_LOCATION在Android 6上不起作用

ACCESS_COARSE_LOCATION在Android 6上不起作用

这个问题已经在这里有了答案:            >            Android permission doesn’t work even if I have declared it                                    12个
我按照官方的例子来写这个程序

public class BluetoothActivity extends AppCompatActivity {
    private static final long SCANNING_TIMEOUT = 5000; /* 5 seconds */
    private static final int ENABLE_BT_REQUEST_ID = 1;
    private BleWrapper mBleWrapper = null;
    private boolean mScanning = false;
    private Handler mHandler = new Handler();
    private BluetoothAdapter mBluetoothAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bluetooth);
        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUetoOTH_LE)) {
            Toast.makeText(this, "no ble", Toast.LENGTH_SHORT).show();
            finish();
        }
        final BluetoothManager bluetoothManager =
                (BluetoothManager) getSystemService(Context.BLUetoOTH_SERVICE);
        mBluetoothAdapter = bluetoothManager.getAdapter();
        if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBtIntent, 1);
        }
        scanLeDevice(true);


    }
    private BluetoothAdapter.LeScanCallback mLeScanCallback =
            new BluetoothAdapter.LeScanCallback() {
                @Override
                public void onLeScan(final BluetoothDevice device, int RSSi,
                                     byte[] scanRecord) {
                    Log.v("ble",device.getName());
                }
            };
    // Stops scanning after 10 seconds.
    private static final long SCAN_PERIOD = 3000;
    private void scanLeDevice(final boolean enable) {
        if (enable) {
            // Stops scanning after a pre-defined scan period.
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mScanning = false;
                    mBluetoothAdapter.stopLeScan(mLeScanCallback);
                }
            }, SCAN_PERIOD);

            mScanning = true;
            mBluetoothAdapter.startLeScan(mLeScanCallback);
        } else {
            mScanning = false;
            mBluetoothAdapter.stopLeScan(mLeScanCallback);
        }
    }
}

这是manifests.xml中的权限

<uses-permission android:name="android.permission.BLUetoOTH" />
<uses-permission android:name="android.permission.BLUetoOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

但是我仍然有这个例外

03-24 15:52:01.126 2223-2236/com.test W/Binder: Caught a RuntimeException from the binder stub implementation.
03-24 15:52:01.126 2223-2236/com.test W/Binder: java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results

如何使BLE在Android 6上工作,我的设备的Android版本为6.0.1

为什么我添加了该权限,但仍然有该异常?

解决方法:

Andorid M功能在运行时请求权限.这意味着在安装您的应用程序后,它尚无使用蓝牙的权限.用户必须手动授予该权限(每次安装一次).

只需遵循官方指南-> Requesting Permissions at Run Time

android – FCM通知click_action不起作用

android – FCM通知click_action不起作用

我有FCM的问题,当我收到通知时,我希望它打开特定的活动,默认情况下,当我不添加click_action时,它会打开应用程序的主要活动,但是当我添加click_action并单击通知时它不会执行任何操作.

这是我在Web服务中使用的JSON:

{
    "registration_ids": [
        "f4............LL"
    ],
    "notification": {
        "title": "Rebate Confirmation",
        "text": "Please Confirm",
        "sound": "default",
        "click_action": ".Activities.CustomerRebateConfirmation"
    },
    "data": {
        "merchant_id": "20",
        "customer_id": "1",
        "points": "10",
        "totalpoints": "100",
        "message": "Please Confirm",
        "type": "customer_points_rebate_confirmation"
    }
}

这是我的onMessageReceived方法:

public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.e(TAG, "From: " + remoteMessage.getFrom());
        customerRebateDetails = new String[5];

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.e(TAG, "Message data payload: " + remoteMessage.getData());
            Log.e(TAG, "Message notification: " + remoteMessage.getNotification().getBody());

            String type = remoteMessage.getData().get("type");
            String message = remoteMessage.getData().get("message");
            String text = remoteMessage.getNotification().getBody();
            Uri defaultSoundUri = ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION);

            switch (type){
                case "customer_points_rebate_confirmation":
                    customerRebateDetails[0]  = remoteMessage.getData().get("customer_id");
                    customerRebateDetails[1]  = remoteMessage.getData().get("merchant_id");
                    customerRebateDetails[2]  = remoteMessage.getData().get("points");
                    customerRebateDetails[3]  = remoteMessage.getData().get("totalpoints");
                    Intent customerRebate = new Intent(this, CustomerRebateConfirmation.class);
                    customerRebate.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    customerRebate.putExtra("customer_points_rebate_confirmation", customerRebateDetails);
                    PendingIntent customerRebatePendingIntent = PendingIntent.getActivity(this, 0, customerRebate,
                            PendingIntent.FLAG_ONE_SHOT);
                    NotificationCompat.Builder customerRebateBuilder = new  NotificationCompat.Builder(this)
                            .setSmallIcon(R.mipmap.ic_launcher)
                            .setContentTitle(message)
                            .setContentText(text)
                            .setSound(defaultSoundUri)
                            .setAutoCancel(true)
                            .setContentIntent(customerRebatePendingIntent);
                    notificationmanager customerRebateManager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE);
                    customerRebateManager.notify(0, customerRebateBuilder.build());
                    break;
            }

有谁知道实施的问题是什么?

请注意,当应用程序处于前台时,它可以正常工作,但当应用程序处于后台时,它无法正常工作.

解决方法:

确保在Manifest文件中的CustomerRebateConfirmation活动中添加了这一行…

<intent-filter>
     <action android:name=".Activities.CustomerRebateConfirmation" />
     <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

android – iframe标签在最新版本的Ionic中不起作用

android – iframe标签在最新版本的Ionic中不起作用

我按照Ionic框架的教程学习如何构建应用程序:https://thinkster.io/ionic-framework-tutorial/
它运作得很好.

然后我开始添加功能,比如一个带有iframe标签的页面,它也在android模拟器中工作.但是当我从头开始构建我自己的应用程序时,iframe仅在您使用ionic serve –lab运行应用程序时才有效,它在模拟器或真正的Android设备中不起作用.

我的应用程序和示例教程之间的主要区别在于本教程是使用Ionic v1.0.0-beta.14(我认为Apache Ant)构建的,而我的应用程序是使用Ionic v1.0.0-rc.4

有没有办法来解决这个问题?

这是代码,很简单:

<ion-view view-title="Detalles de mensaje">
  <ion-nav-buttons side="right">
   <buttonng-click="openPopover($event)">
   </button>
  </ion-nav-buttons>

  <ion-content scroll="false">

      <iframe src="http://www.cnn.com/" height="400px" width="350px"></iframe>

    <div>
      <div>
        <buttonng-ng-click="openPage()">
          {{ 'NO SE MUESTRA CONTENIDO' }}
        </button>
      </div>
    </div>

    </ion-content>
</ion-view>

解决方法:

我刚刚开始使用Ionic并且遇到了完全相同的问题 – iFrames在浏览器预览中工作但其他地方都没有.我在this SO post回答了问题,现在他们正在工作.

必须将白名单功能添加到应用程序中,通过在项目目录中运行ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git来实现.

您可能还必须将您引用的外部网站列入白名单.例如:

.config(function ($sceDelegateProvider) {
    $sceDelegateProvider.resourceUrlWhitelist(['self', 'http://www.cnn.com/']);
}); 

android – Style在Button上不起作用

android – Style在Button上不起作用

这是我的Button for XML:

<Buttonandroid:id="@+id/Button01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="Some text"
  />

这是Button的样式XML:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Btest" parent="@android:style/Widget.Button">
        <item name="android:textColor">#FFFFFFFF</item>
        <item name="android:textSize">16dip</item>
        <item name="android:textStyle">bold</item>
    </style>
</resources>

但是,样式XML对Button没有影响.如果我跳过样式XML并直接在Button XML中应用样式,那么事情就会按预期工作.

我错过了什么?

解决方法:

您是否因为特定原因使用parent =“@ android:style / Widget.Button”?您只需要在从其他样式继承时指定父级.如果删除它会怎么样?

我们今天的关于输入最大长度在Android -Ionic上不起作用输入文本最大长度的分享已经告一段落,感谢您的关注,如果您想了解更多关于ACCESS_COARSE_LOCATION在Android 6上不起作用、android – FCM通知click_action不起作用、android – iframe标签在最新版本的Ionic中不起作用、android – Style在Button上不起作用的相关信息,请在本站查询。

本文标签: