###前提・実現したいこと
BLE機器とandroid(Experia)を繋げてRSSIを用いて距離表示するアプリケ―ションを作りたいと思っています。
andorid studioにおけるBluetoothパーミッション設定を行いたいのですが、以下のエラーメッセージが発生しました。
###発生している問題・エラーメッセージ
Error:No resource found that matches the given name (at 'value' with value '@string/nearby_api_key').
Error:No resource found that matches the given name (at 'value' with value '@string/nearby_api_key').
###該当のソースコード
java(以下mainactivity.javaのコピーです。bluettothver2は自分で作成したファイル名です)
package com.example.bluetoothver2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
//以下追加
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import jp.blecontroller.PeripheralActivity;
public class MainActivity extends Activity {
private Button mBtnOpenCentral; private Button mBtnOpenPeripheral; private final static int REQUEST_PERMISSIONS = 1; private final static int SDKVER_MARSHMALLOW = 23; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // デバイスがBLEに対応していなければトースト表示. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } // Android6.0以降なら権限確認. if(Build.VERSION.SDK_INT >= SDKVER_MARSHMALLOW) { this.requestBlePermission(); } mBtnOpenCentral = (Button)findViewById(R.id.btn_open_central); mBtnOpenCentral.setOnClickListener(mBtnOpenCentralClicked); mBtnOpenPeripheral = (Button)findViewById(R.id.btn_open_peripheral); mBtnOpenPeripheral.setOnClickListener(mBtnOpenPeripheralClicked); } @TargetApi(SDKVER_MARSHMALLOW) private void requestBlePermission(){ // 権限が許可されていない場合はリクエスト. if(checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){ requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION },REQUEST_PERMISSIONS); } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { // 権限リクエストの結果を取得する. if (requestCode == REQUEST_PERMISSIONS) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(MainActivity.this, "Succeed", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, "Failed", Toast.LENGTH_SHORT).show(); } }else { super.onRequestPermissionsResult(requestCode, permissions, grantResults); } }
public class MainActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); }
}
###試したこと
エラーコードを打って検索してみましたが有力な情報が得られませんでした。
###補足情報(言語/FW/ツール等のバージョンなど)
blueoothパーミッションについて教えて頂けると幸いです。
あなたの回答
tips
プレビュー