我正在开发基于Firebase数据库和存储的聊天应用程序.一切都运行正常,但现在我需要实施FCM,以便在应用程序处于后台或前台时接收应用程序通知.我找不到在PHP中实现的方法来监听firebase数据库中的任何更改,如果有任何更改,则将推送通知发送到应用程序.
有很多代码可以从PHP发送通知,但没有一个基于Firebase数据库,甚至官方文档都有我的共享主机不支持的Node.js指南.
我已经在我的应用程序端实现了FCM代码,该代码已经过Firebase控制台测试.
php firebase firebase-realtime-database firebase-cloud-messaging firebase-storage
我正在开发一个应用程序,我只使用1个主要活动和多个片段,包括ViewPager,自定义视频/图像库,全屏片段(没有工具栏或底部导航按钮).我不确定这是好的做法,但我面临的问题很少.
上图是实际的App层次结构.在我面临的问题之后.
using: getSupportActionBar().setDisplayHomeAsUpEnabled(true);然后后箭头打开抽屉但不回到最后片段.Fragment使用Single 执行所有任务是否是一种好习惯Activity.我也在使用单个工具栏整个应用程序.Toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/toolbar_connections"
android:visibility="visible"
android:orientation="horizontal">
<ImageView
android:layout_width="35dp"
android:layout_height="match_parent"
android:id="@+id/appLogo"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="22sp"
android:id="@+id/activityTitle"
android:textColor="@color/primary_text"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/toolbar_chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
android:src="@drawable/baby"
android:id="@+id/User_Image_Toolbar"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/User_Name_Toolbar"
android:textSize="17sp"
android:textStyle="bold"
android:layout_marginBottom="5dp"
android:text="My Name"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Online" …Run Code Online (Sandbox Code Playgroud) android toolbar android-fragments android-actionbar navigation-drawer
我需要Arraylist在不使用任何库的情况下将图像上传到服务器。我正在使用Asynctask上传单个图像,它在 httpurlconnection multipart/form-data 的帮助下完美运行。现在我需要更改我的代码以使用上传任何类型的多个文件,Arraylist<String>但我的问题是现有代码FileinputStream不支持 arraylist,我不知道使用什么而不是Fileinputstream将 arraylist 上传到服务器,我不知道也想为此使用任何库。
public class multipart_test extends AsyncTask<Void,Void,String> {
Context context;
String Images;
public static final String TAG = "###Image Uploading###";
public multipart_test(Context context,String Upload_Images) {
this.context = context;
this.Images = Upload_Images;
}
@Override
protected String doInBackground(Void... params) {
BufferedReader reader;
String WebPath = null;
try {
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int …Run Code Online (Sandbox Code Playgroud) 我需要在ActivityRecognition Detect用户状态(每隔3分钟调用一次)之后获取用户的位置(通过fusionlocation API),如IN_VEHICLE,ON_FOOT,RUNNING等.
在每个事件上,我需要定期间隔后的用户位置例如:
如果用户仍然是,那么setInterval(5*60*60*1000);在5小时之前检查下一个位置更新.但ActivityRecognation将每3分钟调用一次.
如果用户正在运行,则setInterval(2*60*1000);在2分钟之前/之后检查下一个位置更新.但ActivityRecognation将每3分钟调用一次.
如果用户正在运行,则如果用户正在驾驶,则每隔1分钟发送一个位置,然后每15分钟发送一次位置.
我试图onConnected在类级别将boolean false设置为false和true.但它总是变成真实的,因为整个Intent服务在3分钟后被调用.
if (startLocationFirst){
requestLocatonSetting(5*60*60*1000,3*60*60*1000,LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationAPIclient.connect();// RequestLocation and GoogleAPIClient won't call until device comes from another ActivityRecognation State running,walking etc. And keep Updating location every 5 hours.
}
Run Code Online (Sandbox Code Playgroud)
问题我现在有
startLocationFirst布尔值,直到它来自另一个ActivityRecognation状态并保持更新位置设置为内部startLocationFirst这是带有FusedLocation的IntentService
public class Activity_Recognized_Service extends IntentService implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks, LocationListener {
/**
* Creates an IntentService. Invoked by your subclass's constructor.
*
* @param name Used to name the worker thread, important only for …Run Code Online (Sandbox Code Playgroud) 我有片段与布局CoordinatorLayout与内部NestedScrollView和内nestedscrollview我有ViewPager和TabLayout同片段.标签是可见的,但与标签相关的片段未加载.
布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true"
android:background="?android:attr/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!--app:contentScrim="?attr/colorPrimary" -->
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ViewPagerImages"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:scrollIndicators="top|right">
</android.support.v4.view.ViewPager>
<ProgressBar
android:layout_width="120dp"
android:layout_height="120dp"
android:id="@+id/Progress_Bar_Image"
android:layout_gravity="center_horizontal|center_vertical"
android:visibility="visible"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right|top"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="@drawable/round_default"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="/5"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="bottom"
android:padding="15dp"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/unsa"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="@+id/user_S" …Run Code Online (Sandbox Code Playgroud) android adapter android-fragments android-viewpager android-tablayout
我试图让我的布局像这样,但我无法像这样用圆角制作我的图像视图。它在 Android Studio 的布局编辑器中完美显示,但在实际设备中我得到了平角。我厌倦了 XML 和代码,但没有为我工作。请帮助我像这个示例图像一样制作我的布局。
我的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:clickable="true"
android:background="?android:attr/colorBackground"
android:focusable="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="170dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/User_CoverPhoto"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:background="@drawable/round_shape_only"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/User_CoverPhoto"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/User_ProfilePictures"
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:layout_width="230dp"
android:layout_height="match_parent"
android:background="@drawable/round_shape_only"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/User_ProfilePictures"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="#40000000"
android:backgroundTint="#CC000000"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Profile Picture"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent" …Run Code Online (Sandbox Code Playgroud)