正在玩渐进的网络应用程序.我试图让网络应用程序安装横幅工作,但我service worker does not successfully serve the manifest's start_url在使用Lighthouse调试后继续收到(下图).目前我正在使用azure托管我的网站.
新: 我检查了所有缓存,start_url,以及我的服务工作者,看看一切都匹配.但它仍然给我同样的错误.
我不确定这是start_url我的service-worker问题还是我的问题.以下是我的代码.
manifest.json
{
"short_name": "MY EXPERTS",
"name": "MYEXPERT",
"icons": [
{
"src": "Images/petronas_logo_192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "Images/petronas_logo_192.png",
"type": "image/png",
"sizes": "512x512"
}
],
"background_color": "#FFFFFF",
"theme_color": "#67BCFF",
"display": "standalone",
"start_url": "/Home/Index"
}
Run Code Online (Sandbox Code Playgroud)
AddServiceWorker.js
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js').
then(function (registration) {
// Registration was successful``
console.log('ServiceWorker registration successful with scope: ',
registration.scope);
}).catch(function (err) {
// registration failed …Run Code Online (Sandbox Code Playgroud) 每当我使用我SimpleDateFormat的android时,它一直给我错误调用需要API级别24.这是没有意义的,因为我参考这个教程已经有几年了.
这是给出错误的代码
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM,yyyy HH:mm:ss");
我甚至尝试但它仍然无法正常工作
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM,yyyy HH:mm:ss",Locale.US);
这是我遇到问题的方法
public static long getDateInMillis(String srcDate) {
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM yyyy HH:mm:ss");
long dateInMillis = 0;
try {
Date date = formatter.parse(srcDate);
dateInMillis = date.getTime();
return dateInMillis;
}
catch (java.text.ParseException e) {
e.printStackTrace();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 基本上,我在三(3)个不同的片段中有三(3)个复选框列表。当我打开活动时,默认片段中的复选框显示为正常,但不同片段中的复选框显示为不同。复选框的值仍然为true。下面是复选框的图像,它使内容和我的代码更加清晰。
第一个片段页面:
第二个片段页面:
设置复选框及其代码的代码 if condition
private void setCheckBox(ArrayList<DataPrefType> arrayList){
for(int i = 0; i < arrayList.size(); i++){
id = i + 1;
checkBox = new CheckBox(getActivity());
checkBox.setId(i + 1);
checkBox.setText(arrayList.get(i).getName());
checkBox.setPadding(10, 10, 10, 10);
checkBox.setLayoutParams(params);
checkBox.setGravity(Gravity.CENTER);
checkBoxLayout.addView(checkBox);
if(!userPreference.isEmpty() || userPreference != null){
for(int j = 0; j < userPreference.get(0).getDataPrefTypeArrayList().size(); j++){
int retrieveId = Integer.parseInt(userPreference.get(0).getDataPrefTypeArrayList().get(j).getId());
if(checkBox.getId() == retrieveId)
checkBox.setChecked(true);
}
}
Run Code Online (Sandbox Code Playgroud) 我目前有这个标签视图,我在本教程中遵循了这个视图.一切正常,直到我注意到onCreateView没有在任何标签上调用.我在这里和那里寻找解决方案,但我仍然无法解决.这是我的代码:
activity_pref_main_container.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
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_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
PrefMainActivity.class
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) …Run Code Online (Sandbox Code Playgroud) android android-fragments android-tablayout fragment-oncreateview