package com.yazilimevi.unfollow.CustomViews;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull;
import com.yazilimevi.unfollow.InsClient;
import com.yazilimevi.unfollow.MainActivity;
import com.yazilimevi.unfollow.R;
import com.yazilimevi.unfollow.insterfaces.AuthenticationListener;
public class AuthenticationDialog extends Dialog {
private AuthenticationListener listener;
private Context context;
private WebView webView;
private final String url = InsClient.BASE_URL
+"oauth/authorize/?client_id="
+InsClient.INSTAGRAM_CLIENT_ID
+"&redirect_uri="
+InsClient.REDIRECT_URI
+"&response_type=token"
+"&display=touch&scope=public_content";
public AuthenticationDialog(AuthenticationListener listener, @NonNull Context context) {
super(context);
this.context = context;
this.listener = listener;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.auth_dialog);
initializeWebView();
}
private void initializeWebView() {
webView = (WebView) findViewById(R.id.webView);
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient(){
String access_token;
boolean authComplete;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
/* WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);*/
if (url.contains("#access_token=") && !authComplete){
Uri uri = Uri.parse(url);
access_token = uri.getEncodedFragment();
access_token = access_token.substring(access_token.lastIndexOf("=")+1);
authComplete = true;
listener.onCodeReceived(access_token);
dismiss();
}
else if (url.contains("?error")){
System.out.println("çıktı");
dismiss();
}
}
});
}
}
url.contains("#access_token=") It translates to false and Instagram webview does not work. I added Instagram API and client ids. I call the dialog in the main activity section, but only the Instagram logo appears in the dialog that opens. url.contains("#access_token=") It translates to false and Instagram webview does not work. I added Instagram API and client ids. I call the dialog in the main activity section, but only the Instagram logo appears in the dialog that opens. url.contains("#access_token=") It translates to false and Instagram webview does not work. I added Instagram API and client ids. I call the dialog in the main activity section, but only the Instagram logo appears in the dialog that opens.
URL.CONTAINS(“#ACCESS_TOKEN=”)它会转换为FALSE,并且Instagram Webview无法工作。我添加了Instagram API和客户端ID。我在主活动部分调用了该对话框,但在打开的对话框中只出现了Instagram徽标。URL.CONTAINS(“#ACCESS_TOKEN=”)它会转换为FALSE,并且Instagram Webview无法工作。我添加了Instagram API和客户端ID。我在主活动部分调用了该对话框,但在打开的对话框中只出现了Instagram徽标。URL.CONTAINS(“#ACCESS_TOKEN=”)它会转换为FALSE,并且Instagram Webview无法工作。我添加了Instagram API和客户端ID。我在主活动部分调用了该对话框,但在打开的对话框中只出现了Instagram徽标。
`public static final String GET_USER_INFO_URL = "https://api.instagram.com/v1/users/self/?access_token=";
public static String INSTAGRAM_CLIENT_ID ="685551893072923";
public static String INSTAGRAM_CLIENT_ID_SECRET ="7b599f18f96677b83053241599686f42";
public static String BASE_URL ="https://api.instagram.com/";
public static String REDIRECT_URI = "https%3A%2F%2Fwww.instagram.com/";
public final static String PREF_NAME = "app_pref";`
I'm waiting for your help I'm waiting for your help I'm waiting for your help I'm waiting for your help
我在等你的帮助我在等你的帮助
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!