Android USB テザリング 経由で 100Mbps を超える

docomo PREMIUM 4G で 100Mbps 越えていたので

自宅のプロバイダ契約いらないのではないかと思い,

Android経由でテザリングしてみました.

Bluetooth や Wifi 経由でもテザリングはできますが,

最速の有線なUSBテザリングです.

Android側でテザリング設定してUSBでラップトップPCと接続して,

PC側でそれを通信に使うように設定変更します.

すると,

ほとんどそのままPCまで伝わります100Mbps.

Speedtest by Ookla - The Global Broadband Speed Test

あとは, 自宅プロバイダ解約までに必要なのは,

docomo契約プランの

「通信量制限」

となりました.

数ヶ月前に, docomo は契約プランを大きく変更していますよね.

(つづく)

docomo spモードが 実効速度 100Mbps をかるく越えてる件

通信量制限のことは「docomo WiFi」で忘れてよし!


「Kindle Fire HD 8」の対応ファイルとインテントフィルター

「電子書籍」とひとことにいっても, 実は, ファイル形式やリーダー端末やアプリなど利用方法をさまざま.

Fire HD を買ってみたのですがそんな調査と使い方を少し探ってみようと.

いうても, Android 5.1 だろよ, とな.

インテントフィルター

デフォルトでインストールされている 電子書籍リーダーとしての Kindle アプリ.

AndroidManifest を見てみると以下抜粋.


...
<activity
    android:theme="@2131624707"
    android:label="@2131230864"
    android:icon="@2130839461"
    android:name="com.amazon.kindle.TabletStartActivity"
    android:launchMode="singleInstance"
    android:configChanges="orientation|screenLayout|screenSize">
    <meta-data
        android:name="restriction_filter"
        android:resource="@2131296307"/>

    <intent-filter>
        <action
            android:name="android.intent.action.MAIN"/>
        <category
            android:name="android.intent.category.LAUNCHER"/>
        <category
            android:name="android.intent.category.DEFAULT"/>
    </intent-filter>

    <intent-filter>
        <action
            android:name="android.intent.action.VIEW"/>
        <category
            android:name="android.intent.category.DEFAULT"/>
        <category
            android:name="android.intent.category.BROWSABLE"/>
        <data
            android:scheme="kindle"/>
    </intent-filter>

    <intent-filter>
        <action
            android:name="android.intent.action.VIEW"/>
        <category
            android:name="android.intent.category.DEFAULT"/>
        <category
            android:name="android.intent.category.BROWSABLE"/>
        <data
            android:mimeType="application/x-mobipocket-ebook"
            android:scheme="file"/>
    </intent-filter>

    <intent-filter>
        <action
            android:name="android.intent.action.VIEW"/>
        <category
            android:name="android.intent.category.DEFAULT"/>
        <category
            android:name="android.intent.category.BROWSABLE"/>
        <data
         android:mimeType="application/x-mobi8-ebook"
         android:scheme="file"/>
   </intent-filter>

   <intent-filter>
      <action
         android:name="android.intent.action.VIEW"/>
      <category
         android:name="android.intent.category.DEFAULT"/>
      <category
         android:name="android.intent.category.BROWSABLE"/>
      <data
         android:mimeType="application/pdf"
         android:scheme="file"/>
   </intent-filter>

   <intent-filter>
      <action
         android:name="android.intent.action.VIEW"/>
      <category
         android:name="android.intent.category.DEFAULT"/>
      <category
         android:name="android.intent.category.BROWSABLE"/>
      <data
         android:mimeType="application/pdf"
         android:scheme="content"/>
   </intent-filter>

   <intent-filter>
      <action
         android:name="android.intent.action.VIEW"/>
      <category
         android:name="android.intent.category.DEFAULT"/>
      <category
         android:name="android.intent.category.BROWSABLE"/>
      <data
         android:scheme="file"
         android:host="*"
         android:pathPattern=".*pdf"/>
   </intent-filter>

</activity>
...

レガシーなスタイルの file スキーマからしか mobi ファイルは読みません.
pdfファイルに関しては content スキーマから読むことができます.

よって, 外部ファイルに対して kindle アプリをリーダーとして使うためには以下のファイル形式と配置が必要になります.

- pdf ファイル
- デバイスローカルに配置した mobi ファイル

epub 形式は直接は開けません.

意外と使えないようですがさらに調べていきます.

(→ つづく)


Convert Java File to Kotlin の後に その1「メンバとコンストラクタ」

まずは「Convert Java File to Kotlin」で変換してなんとなくは動いていますが.

一通り公式リファレンスは流し読みしていましたが

コードをみているとKotolinの持つ恩恵を得ているような気がしません.

逆に分かりづらくなったようにも思えたりします.

先人たちのコードを見ながら自然なKotlinコードに書き換えていきましょう.

メンバとコンストラクタ

以下のようなJavaコード.


public class TasksPresenter implements TasksContract.Presenter {

    private final TasksRepository mTasksRepository;

    private final TasksContract.View mTasksView;

    private TasksFilterType mCurrentFiltering = TasksFilterType.ALL_TASKS;

    private boolean mFirstLoad = true;

    public TasksPresenter(@NonNull TasksRepository tasksRepository, @NonNull TasksContract.View tasksView) {
        mTasksRepository = checkNotNull(tasksRepository, "tasksRepository cannot be null");
        mTasksView = checkNotNull(tasksView, "tasksView cannot be null!");

        mTasksView.setPresenter(this);
    }

android-architecture/TasksPresenter.java at todo-mvp · googlesamples/android-architecture

Kotlin のプロパティを使って適切に初期化します. ほとんどのメンバ変数に割り当てられたコンストラクタパラメータは必要ありません.


class TasksPresenter(val tasksRepository: TasksRepository, val tasksView: TasksContract.View)
    : TasksContract.Presenter {

    override var filtering = TasksFilterType.ALL_TASKS

    private var mFirstLoad = true

    init {
        tasksView.setPresenter(this)
    }

主コンストラクタに注釈や可視性修飾子がない場合は、コンストラクタキーワードを省略できます。

Classes and Inheritance - Kotlin Programming Language

Convert Java File to Kotlin の後に その1「メンバとコンストラクタ」

Convert Java File to Kotlin の後に その2 「apply」

Convert Java File to Kotlin の後に その3 「Null Safety」

Convert Java File to Kotlin の後に その4 「lateinit」

Convert Java File to Kotlin の後に その5 「String Templates」