我想在其中不断显示小图标status bar,而不显示notification系统托盘上的通知本身.
我尝试使用自定义layout并将根元素的可见性设置为View.GONE,或者View.INVISIBLE,对于两者,系统忽略它.
我也尝试设置根元素的高度,但系统也忽略了这一点.
这是我的代码:
R.layout.custom_notification:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/custom_notification"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/notif_background"
android:orientation="horizontal"
android:baselineAligned="false"/>
Run Code Online (Sandbox Code Playgroud)
并显示以下代码Notification:
NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx);
mBuilder
.setSmallIcon(drawableId)
.setAutoCancel(false)
.setOngoing(true)
.setPriority(Notification.PRIORITY_MAX);
Intent resultIntent = new Intent(ctx, SettingsActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(ctx, 0, resultIntent, 0);
mBuilder.setContentIntent(resultPendingIntent);
int layout = R.layout.custom_notification ;
RemoteViews contentView = new RemoteViews(ctx.getPackageName(), layout);
contentView.setViewVisibility(R.id.custom_notification, View.INVISIBLE);
mBuilder.setContent(contentView);
nm.notify(NOTIFICATION_ID, mBuilder.build());
Run Code Online (Sandbox Code Playgroud)
我很清楚,为了实现我的目标,我不需要记录解决方案.而且我也知道UX准则强烈建议不做这样的事情.所以没有必要把这个作为答案写给我.
(编辑我添加了一个小的演示测试)
我是新手Retrofit.我需要做的是XML从服务器检索文件并将其转换为POJO.问题是我的测试服务器上的所有内容都与静态文件完美配合,但是当我在真实服务器上尝试这个时,我无法使用它Retrofit2,但是当我直接使用时它确实有效OkHttp,所以有些东西是错误的生成Request我猜.
编辑:我切换代码使用String转换器只是简单的事情,因为问题只与响应有关.
这是我的基本实现.
public interface ZedoClient {
@retrofit2.http.Headers({
"User-Agent: Mozilla/5.0 (Linux; Android 5.1; Quattro_L50_HD LMY47D/Quattro_L50_HD)",
"Cookie : ZCBC=1;FFcat=3533,3,90;FFad=0;FFMChanCap=5345280B3533,3#2605191|0,1#0,24:"
})
@GET("fns.vast")
Call<Vast> getVast(@QueryMap(encoded=true) Map<String, String> options);
Run Code Online (Sandbox Code Playgroud)
我添加了两个Interceptor以便设置headers和cookies:
AddCookiesInterceptor.class
class AddCookiesInterceptor implements Interceptor {
private final Headers headers;
AddCookiesInterceptor(Headers headers) {
this.headers = headers;
}
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
builder.headers(headers);
return chain.proceed(builder.build());
}
}
Run Code Online (Sandbox Code Playgroud)
ReceivedCookiesInterceptor.class …
我正在用Java创建一个家族树程序,或者至少尝试一下.我开发了几个类:
我有两个主要问题:
1)我需要设置人与人之间的关系.目前我在做:
FamilyMember A, FamilyMember B
B.setMother(A);
A.setChild(B);
Run Code Online (Sandbox Code Playgroud)
以上示例用于设置母子关系.
这看起来很笨重.实现所有关系的时间越来越长.关于如何以较少程序的方式实现多个关系的任何想法?
2)我必须能够显示家谱.我怎样才能做到这一点?有没有自定义课程让生活更轻松?
谢谢你的时间...
这是一个倒数计时器,我想在几分钟和几秒钟内打印.ex(300000mili)5分钟,计数4:60,4:59 ......这是我的代码的一部分
final MyCounter timer = new MyCounter(300000,1000);
blue.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
timer.start();
}
});
}
public class MyCounter extends CountDownTimer {
public MyCounter(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
blue.setText("Live");
}
@Override
public void onTick(long millisUntilFinished) {
blue.setText((millisUntilFinished/60000)+":"+(millisUntilFinished/5000));
// i tried this
}
}
Run Code Online (Sandbox Code Playgroud)
如何在失踪20秒后振动?什么时候结束?谢谢,抱歉我的英语不好