K
K
kykyllllka2016-03-02 14:54:14
Android
kykyllllka, 2016-03-02 14:54:14

How to add a channel from www.twitch.tv to the app?

In general, I decided to add to my application, twitch stream. Made by stackoverflow.com/questions/30313933/playing-twitc...
Here is my code.

<WebView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/webview1"
        android:layout_marginBottom="137dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignRight="@+id/tableLayout"
        android:layout_alignEnd="@+id/tableLayout" 


JAVA

package com.example.kyky.papi4bingo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageButton;



public class list2 extends AppCompatActivity {

    ImageButton button;
    String url = "http://twitch.tv/dotamajorru/embed";
    WebView mWebView;
    boolean bIcon = true;




    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.list2);



        mWebView = (WebView) findViewById(R.id.webview1);
        button = (ImageButton) findViewById(R.id.button);

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (bIcon)
                    button.setImageResource(R.drawable.tiltedyes);
                else button.setImageResource(R.drawable.tilted);
                bIcon = !bIcon;
            }
        });


        mWebView.setWebChromeClient(new WebChromeClient());
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        mWebView.loadUrl(url);
    }
}

The application compiles, but the stream itself is not added. Gives Failed to open the web page. An error occurred while loading the web page twitch.tv/dotamajorru/embed for the following reasons: net::ERR_CASHE_MISS
On the forums, I found a suggestion to add to the AndroidManifest. Added.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.kyky.papi4bingo" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >

        <activity android:name=".MainActivity" android:screenOrientation="portrait">
             <uses-permission android:name="android.permission.INTERNET" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".list2" android:screenOrientation="portrait">
        </activity>
    </application>

</manifest>

But it did not help, I hope you have encountered a similar problem, and help me find a solution to the problem. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kykyllllka, 2016-03-02
@kykyllllka

Passed out for application earned, but not as I wanted. My browser turns on and opens a link there. And I wanted to have a stream window in the application. Is it possible?

N
Nicholas, 2016-03-02
@ACCNCC

cordova

O
one pavel, 2016-03-02
@onepavel

try instead
mWebView.setWebChromeClient(new WebChromeClient());
use
mWebView.setWebViewClient(...);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question