我最近更新了我的应用程序,通过FCM发送消息,当应用程序在Jelly Bean上运行时,它运行良好.问题是,它不是棒棒糖和应用程序在后台.
我阅读了文档,并指出当有效载荷是数据消息时,它将由onMessageReceived()处理.我发送数据有效负载,而不是通知,只要它是JellyBean就可以正确处理.对于Lollipop,它仅在应用程序位于前台时处理消息.如果没有,没有任何反应.
这就是我的FirebaseMessagingService的开头如下所示:
public class FirebaseBroadcastReceiverService extends FirebaseMessagingService {
private final String TAG = FirebaseBroadcastReceiverService.class.getName();
@Override
public void onMessageReceived(RemoteMessage message){
Log.i(TAG, "A message is received");
String from = message.getFrom();
Map<String, String> data = message.getData();
.....
}
}
Run Code Online (Sandbox Code Playgroud)
清单:
<application
android:name=".controller.application.AppResources"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_shadow"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Black.NoTitleBar">
<service
android:name=".model.firebase.FirebaseListenerService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service android:name=".model.firebase.FirebaseBroadcastReceiverService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
.......
</application>
Run Code Online (Sandbox Code Playgroud)
有效载荷:
{
"data": {
"test": …Run Code Online (Sandbox Code Playgroud) E/StorageException:发生了StorageException.发生未知错误,请检查HTTP结果代码和服务器响应的内部异常.代码:-13000 HttpResult:400
E/StorageException: The server has terminated the upload session
java.io.IOException: The server has terminated the upload session
at com.google.firebase.storage.UploadTask.zzcyp(Unknown Source)
at com.google.firebase.storage.UploadTask.zzcyo(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
E/MainActivity: onFailure sendFileFirebase An unknown error occurred, please check the HTTP result code and inner exception for server response.
Run Code Online (Sandbox Code Playgroud)
这是我为图片上传编写的代码
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(Util.URL_STORAGE_REFERENCE).child(Util.FOLDER_STORAGE_IMG);
final String name = DateFormat.format("yyyy-MM-dd_hhmmss", new Date()).toString();
StorageReference imageGalleryRef = storageReference.child(name + "_gallery");
UploadTask uploadTask = …Run Code Online (Sandbox Code Playgroud) 我试图Firebase在奥利奥版本中显示通知,所以当我得到解决方案时它没有显示
NotificationCompat.Builder(this, CHANNEL_ID)但它显示我这样
我的build.gradle文件是
apply plugin: 'com.android.application'
dependencies {
compile project(':library')
compile project(':camerafragment')
compile 'com.google.android.gms:play-services:11.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.google.firebase:firebase-messaging:11.0.0'
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.0'
compile 'net.gotev:uploadservice:2.1'
compile 'com.google.firebase:firebase-auth:11.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:support-v4:26.0.0-alpha1'
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.trashmap"
minSdkVersion 17
targetSdkVersion 27
// Enabling multidex support. …Run Code Online (Sandbox Code Playgroud) android android-notifications android-support-library firebase-cloud-messaging
我想要实现什么?我想获取捕获图像的URI并将其保存在Firebase上.我尝试了什么?首先,我需要打开相机.以下是我的表现:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(getActivity().getPackageManager()) != null)
startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)
捕获图像后,我需要获取图像的URI.以下是我的表现:
if (resultCode == Activity.RESULT_OK) {
if (requestCode == CAMERA_REQUEST_CODE) {
if (data != null) {
if (data.getData() != null) {
Uri capturedImageUri = data.getData();
} else {
Toast.makeText(getContext(), getString(R.string.coudldnt_get_photo), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getContext(), getString(R.string.coudldnt_get_photo), Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
一切都很好.但仅限于某些设备.我认为它仅适用于超过21个设备的API级别.在其他设备中,getData()返回null.
那么,接下来我做了什么?我发现我可以通过以下代码获取图像的Bitmap:
Bitmap bitmap = (Bitmap)data.getExtras().get("data") ;
Run Code Online (Sandbox Code Playgroud)
所以,我有一个图像的位图.我需要获取此图像的URI.以下是我的表现:
public Uri getImageUri(Context inContext, Bitmap inImage) {
String path =
Images.Media.insertImage(inContext.getContentResolver(), inImage,
"Title", null);
return Uri.parse(path);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码返回我的URI,但图像质量非常差.
所以,我一直在寻找解决方案.并且发现正确的方法是在我启动时创建文件 …
我有一个很好的FrameLayout作为主容器和它的层次结构中的一些其他视图.
但预览显示了一个简单的ActionBarOverlayLayout.
那是什么?为什么在这里?
我有Android Studio 3.0.0
我试过了:重启Android Studio.通过调整大小来刷新预览.更改了预览设备,更改了预览的SDK,更改了蓝图\设计选项,按下了"强制刷新布局" Button.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="match_parent"
android:layout_height="@dimen/walk_list_item_height"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:layout_heightPercent="25%"
app:layout_marginLeftPercent="0%"
app:layout_marginTopPercent="0%"
app:layout_widthPercent="100%"
app:riv_corner_radius="@dimen/corner_radius"
android:id="@+id/walk_iv" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/gradient"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<TextView
android:id="@+id/walk_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="16dp"
android:text="New Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_duration_icon" />
<TextView
android:id="@+id/duration_tv"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:gravity="center|left"
android:text="TextView" …Run Code Online (Sandbox Code Playgroud) 我一直在努力实现这一目标.我想要的是RecyclerView从左到右重叠所选项目,如下图所示.
我可以通过ItemDecoration以下方式实现左或右:
class OverlapDecoration(private val overlapWidth:Int) : RecyclerView.ItemDecoration() {
private val overLapValue = -40
val TAG = OverlapDecoration::class.java.simpleName
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) {
val itemPosition = parent.getChildAdapterPosition(view)
if (itemPosition == 0) {
return
} else {
outRect.set(overLapValue, 0, 0, 0)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过CarouselLayoutManager,但它不是我想要的.
我正在做一个项目,我需要实施一些措施,以便当用户搜索我们的网站时,除了在Google应用中该网站的名称外,它还显示一个应用图标。
如果更多用户已经安装了该应用程序,则可以直接将其重定向到该应用程序。
在这里,我在Firebase应用程序索引编制和应用程序链接(Android Studio 2.3工具)之间感到困惑。有人可以建议我实现该功能需要使用哪种工具,为什么?
提前致谢。
我是Angular5的初学者,我需要你的帮助......
我在我的后端(Java/Spring Boot)中创建了一个API,我可以访问它 http://localhost:8080/applications
使用此API,我想检索一大块数据(它是一个JSON数组).
我尝试在我的Angular上使用httpClient检索数据,但我在前端有这个结果:[object Object]
这是我的app.component.ts
import {Component, Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
url = 'http://localhost:8080/applications';
res = [];
constructor(private http: HttpClient) {
}
ngOnInit(): void {
this.http.get(this.url).subscribe(data => {
this.res = data;
console.log(data);
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log("Client-side error occured.");
} else {
console.log("Server-side error occured.");
}
});
} … 是否有任何工具可以将 Vector Drawable 转换为 SVG?我丢失了原始 svg 文件,现在我想减小图像的大小。目前,我有,
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1200dp"
android:height="1200dp"
android:viewportHeight="1200"
android:viewportWidth="1200">
Run Code Online (Sandbox Code Playgroud)
我想将其设为 180x180。提前致谢。
Gradle DSL method not found: 'testimplementation()'
Run Code Online (Sandbox Code Playgroud)
项目“我的项目”可能使用不包含该方法的 Gradle 版本。构建文件可能缺少 Gradle 插件。应用 gradle 插件
我已经尝试过了
摇篮文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.techknocorp.a.metturcable"
minSdkVersion 14
targetSdkVersion 26
versionCode 532016
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testimplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
androidTestImplementation 'com.android.support.test:runner:1.1.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.1.1'
implementation files('libs/opencsv-2.3.jar')
}
Run Code Online (Sandbox Code Playgroud)
顶级 Gradle // …
android ×8
firebase ×3
angular5 ×1
deep-linking ×1
display ×1
frontend ×1
httpclient ×1
json ×1
uri ×1