google search consoleでrobots.txtとsitemap.xmlを管理

まずsitemap.xmlを作る
changefreqで更新頻度
lastmodifyを動的に出したいが、ここではなし

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!--  created with free sitemap generation system www.sitemapxml.jp  --> 
<url>
  <loc>http://online-shopping.cloud/</loc>
  <priority>1.0</priority>
  <changefreq>always</changefreq>
</url>
<url>
  <loc>http://online-shopping.cloud/ranking.php</loc>
  <priority>0.9</priority>
  <changefreq>daily</changefreq>
</url>
<url>
  <loc>http://online-shopping.cloud/tweet.php</loc>
  <priority>0.8</priority>
  <changefreq>always</changefreq>
</url>
<url>
  <loc>http://online-shopping.cloud/model.php</loc>
  <priority>0.5</priority>
  <changefreq>hourly</changefreq>
</url>
</urlset>

次にrobots.txtでsitemap.xmlを知らせる

User-agent: *Sitemap: http://online-shopping.cloud/sitemap.xml

google search console
ダッシュボードのクロール -> robots.txt テスター

タイトルとurlを表示する

private WebView myWebView;
    private EditText urlText;

    private static final String INITIAL_WEBSITE = "http://hpscript.com/blog/";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        myWebView = (WebView) findViewById(R.id.myWebView);
        urlText = (EditText) findViewById(R.id.urlText);

        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url){
                getSupportActionBar().setSubtitle(view.getTitle());
                urlText.setText(url);
            }
        });
        myWebView.loadUrl(INITIAL_WEBSITE);
    }

webViewを表示する

webViewにブログを表示させます。

public class MainActivity extends AppCompatActivity {

    private WebView myWebView;

    private static final String INITIAL_WEBSITE = "http://hpscript.com/blog/";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        myWebView = (WebView) findViewById(R.id.myWebView);

        myWebView.loadUrl(INITIAL_WEBSITE);
    }
}

WebViewとは?

oracle:https://docs.oracle.com/javase/jp/8/javafx/api/javafx/scene/web/WebView.html
———–
WebViewは、WebEngineを管理し、その内容を表示するNodeです。関連するWebEngineは構築時に自動的に作成され、後で変更できません。WebViewにより、マウス・イベントと一部のキーボード・イベントが処理されて、スクロールが自動的に管理されるため、それをScrollPaneに配置する必要はありません。
WebViewオブジェクトは、FXスレッドからのみ作成およびアクセスする必要があります。

Android Browser

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_weight="1"
            android:id="@+id/urlText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            />
        <Button
            android:text="Browse"
            android:onClick="showWebsite"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

    </LinearLayout>

    <WebView
        android:layout_weight="1"
        android:id="@+id/myWebView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        ></WebView>

</LinearLayout>

Handlerの使い方

new Handler().postDelayed(<Runnable object>,<m seconds>);
private final Runnable func= new Runnable(){
	@Override
	public void run(){
		
	}
};
private Handler mHandler = new Handler();
private Runnable updateText;

@Override
protected void onCreate(Bundle savedInstanceState){
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	updateText = new Runnable(){
		public void run(){
			TextView text = (TextView) findViewById(R.id.count);
			Integer count = Integer.valueOf(text.getText().toString());
			count += 1;
			text.setText(count.toString());
			mHandler.removeCallbacks(updateText);
			mHandler.postDelayed(updateText, 1000);
		}
	};
	mHandler.postDelayed(updateText, 1000);
}

SimpleDateFormat

SimpleDateFormat は、日付のフォーマットと解析を、ロケールを考慮して行うための具象クラスです。これによって、フォーマット (日付 -> テキスト)、解析 (テキスト -> 日付)、および正規化を行うことができます。

SimpledateFormat()
デフォルトのロケール、パターン、日付フォーマット記号を持つ、オブジェクトを生成
SimpledateFormat(String)
指定されたパターン、デフォルトのロケール、日付フォーマット記号を持つ、オブジェクトを生成
SimpledateFormat(String, DateFormatSymbols)
指定されたパターン、日付フォーマット記号を持つ、オブジェクトを生成します。
SimpledateFormat(String, Locale)
指定されたパターン、ロケール、デフォルトの日付フォーマット記号を持つ、オブジェクトを生成

SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd", Locale.US);

sdfって何かと思ったら、simple date formatの略でしょうね。

import java.util.*;
import java.text.*;

class Playground {
    public static void main(String[ ] args) {
        Date date1 = new Date();
        
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy'/'MM'/'dd'?'");
        System.out.println(sdf1.format(date1));
        
        sdf1.applyPattern("yyyy/MM/dd");
        System.out.println(sdf1.format(date1));
    }
}

なるほど、その名の通り、dateformatですね。

runnble 2

class Playground {
    public static void main(String[ ] args) {
        SubThread sub = new SubThread();
        
        Thread thread = new Thread(sub)
        thread.start();
    }
}
    
    class SubSthread implement Runnable{
        public void run(){
            
        }
    }

うまく動きません。。

class Playground {
public static void main(String[ ] args) {
SubThread sub = new SubThread();

Thread thread = new Thread(sub);
thread.start();

for(int i = 0; i < 10; i++){ System.out.println("Lets go cletic"); try{ Thread.sleep(300); } catch(InterruptedException e){ } } } } class SubThread implements Runnable{ public void run(){ for(int i = 0; i < 10; i++){ System.out.println("cleveland"); try { Thread.sleep(500); } catch(InterruptedException e){ } } } } [/java] 500msごとに、他のclassで実行しています。 Lets go cletic cleveland Lets go cletic cleveland Lets go cletic Lets go cletic cleveland Lets go cletic cleveland Lets go cletic Lets go cletic cleveland Lets go cletic Lets go cletic cleveland Lets go cletic cleveland cleveland cleveland cleveland >Javaのクラスは1つのクラスの子クラスにしかなれない制約がある
これに関係していることか?

う~ん、これだと駄目ですね。。

class RacingCar implements Runnable {
private int number = 0;
private static int round = 5;
private static String[] printOffset = {“”, “\t\t\t”,”\t\t\t\t\t\t”};

public RacingCar(int number){
this.number = number;
}

public void run(){
for(int i = 1; i <= round; i++){ try { Thread.sleep((long)(Math.random()* 1000)); } catch(InterruptedException e){ e.printStackTrace(); } System.out.println(printOffset[number-1] + this.number+"号車"+i+"周目通過"); } System.out.println(printOffset[number-1]+ this.number + "号車GOAL!!"); } } [/java] プログラムの実行状態をスレッドといい、全てのプログラムはスレッドによって実行される。javaコマンドが実行されると、JVMは新しいスレッドを作成し、そのスレッドによって指定したクラスのmainメソッドが実行される。mainメソッドの実行が終了するとスレッドは消滅する。

runnable()

run();
オブジェクトが実装するインタフェース Runnable を使ってスレッドを作成し、そのスレッドを開始すると、独立して実行されるスレッド内で、オブジェクトの run メソッドが呼び出される。

class Playground {
private static class Thread {
@Override
public void run(){
for (int i = 0; i < 20; i++){ System.out.println(i + ":" + this.hashCode()); } } } public static void main(String[ ] args) { Thread t1 = new MyThread(); Thread t2 = new MyThread(); t1.start(); t2.start(); } } [/java]