// метод возвращает полный реальный путь до файла, включая имя и расширение
public static String getFilePath(Uri uri) {
Context context = RawPrinterApp.getAppContext();
try {
String selection = null;
String[] selectionArgs = null;
if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
return Environment.getExternalStorageDirectory() + "/" + split[1];
} else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
uri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
} else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
switch (type) {
case "image":
uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
break;
case "video":
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
break;
case "audio":
uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
break;
}
selection = "_id=?";
selectionArgs = new String[]{split[1]};
}
}
if ("content".equalsIgnoreCase(uri.getScheme())) {
String[] projection = {MediaStore.Images.Media.DATA};
try (Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null)) {
int column_index = Objects.requireNonNull(cursor).getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
if (cursor.moveToFirst()) {
return cursor.getString(column_index);
}
} catch (NullPointerException e) {
RawPrinterApp.showToast("error : " + e.getMessage());
e.printStackTrace();
} catch (Exception e) {
RawPrinterApp.showToast("error : " + e.getMessage());
Log.d("RAWBT", "Ignore Exception");
e.printStackTrace();
}
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
}catch (Exception e){
RawPrinterApp.showToast("error : "+e.getMessage());
e.printStackTrace();
}
return "";
}
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'to' => $idустройствасостарницысjs,
'notification' => array (
"body" => $mess,
"title" => $title,
"icon" => "",
"badge" => "",
"click_action"=>"",
),
);
$fields = json_encode ( $fields );
$headers = array (
'Authorization: key=' . "ключфаребасе",
'Content-Type: application/json'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );
$result = curl_exec ( $ch );
вся соль слишком разное железо.
Но это не будет малинкой. Микроконтролеры популярны
а) широкий набор перефирии
б) куча готовых библиотек
в) приличная ИДЕ для разработки и заливки прошивки
г) сообщество единомышлеников.
А с телефонами больше 40 тысяч моделей и полное отсутствие выше перечисленного.
Александр Вертинский, Попробуйте к живому телефону прикрутить
https://smartelements.ru/collection/displei-i-indi...