Youtube アプリを起動後アクティビティに戻れない

81 views
Skip to first unread message

domanthan

unread,
Sep 24, 2011, 12:06:12 PM9/24/11
to android-g...@googlegroups.com
domanthanです。

最近、ずっと同じ問題に悩まされてます。
作成中のアプリからYoutubeのアプリを起動し、再生終わった後「Back」キーで戻るところ、
画面が固まったままになっている。

アプリの大まかな流れは以下のようになっています。

1)ボタンをクリックし、WebViewを起動。
2)Webviewより、Youtubeの検索画面をロードする。
3)検索結果をYoutubeアプリにIntent発行し、起動する。
(ここまでは問題なし)

Youtube再生後、「バック」キーをクリックして、画面は元に戻りましたが、インプットの受付はできない、固まったままになってます。

どなたか同じ経験をされて、解決する方法がありましたら、教えていただきたいです。

ソースの概要:(WebView処理部分)

public void init()  {

   webview = (WebView) context.findViewById(R.id.webviewer);

   webview.setBackgroundColor(0xeeeeeeee);

   webview.getSettings().setJavaScriptEnabled(true);  

   webview.getSettings().setTextSize(TextSize.SMALLEST);

   webview.getSettings().setPluginsEnabled(true);

   webview.getSettings().setUserAgentString(

       "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");

   webview.setWebChromeClient(new WebChromeClient() {

   public void onProgressChanged(WebView view, int progress) {

      updateProgress(progress);

   }

   });

   webview.setWebViewClient(new WebViewClient() {

      public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {

         Toast.makeText(context, "Oh no! " + description,

         Toast.LENGTH_SHORT).show();

         hideProgress();

      }

      public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

          handler.proceed();

      }

      public boolean shouldOverrideUrlLoading(WebView view, String url) {

         if (url.startsWith("vnd.youtube")) {

            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));

            return true;

         } else {

            return false;

         }

      }

    });

}

public void load(String key) {

   showProgress();

   String url = URLBuilder.build(url_domain, "", key);

   webview.loadUrl(url);

   String title = webview.getTitle();

   if (title != null) {

     TextView tv = (TextView) context.findViewById(R.id.web_topic);

     tv.setText(title);

   }

   currentTopic = key;

}

なお、Activityのライフサイクル管理イベントメソッドはViewを初期化するくらいで、特別な処理を実装してません。
Debugしてみたところ、Youtube起動後、ActivityのonPause()とonStop()が呼ばれました。(仕様通り)
Youtube再生後、戻る際にonRestart()が呼び出されたことを期待してましたが、呼び出されませんでした。

OSバージョン: Froyo (2.2)
端末:      Garaxy Tab

以上、よろしくお願い致します

Reply all
Reply to author
Forward
0 new messages