0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidでCyberlink4JavaでControl Pointするときのメモ

0
Last updated at Posted at 2015-11-09

壁にぶつかりながら都度Updateしていきます。

Control Pointのインスタンスは一つに

例えば、Androidのネットワーキングはmainthreadでは出来ないので、非同期でControlPointを定義しようとします。


protected Object doInBackground(Object[] objects) {
   ControlPoint c = new ControlPoint()
   c.start();
   c.search("upnp:rootdevice");
}

これだと二回目の非同期処理でクラッシュします。startのところです。どうもログをみているとControlPointの処理は継続しているようだったので、ControlPointはstaticにしてみたところ、クラッシュはなくなってsearchが何度でもできるようになった。


static ControlPoint mC = null;
protected Object doInBackground(Object[] objects) {
    if( mC == null ){
        mC = new ControlPoint()
    }
    mC.start();
    mC.search("upnp:rootdevice");
}

これでも動きますが、singletonにしてあげたほうがよいですね。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?