在我的应用程序中,我的要求是获取用户照片并在我的应用程序中显示.
为了我的身份验证,获得访问令牌并输入用户名密码,但这表明您无权打开此页面.接下来我如何获得用户个人资料和照片.
我的代码是:
String url ="https://instagram.com/oauth/authorize?" +"response_type=token" +
"&redirect_uri=" + CALLBACK_URL+"&scope=basic"+"&client_id=" + CLIENT_ID ;
WebView webview = (WebView)findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
String fragment = "#access_token=";
int start = url.indexOf(fragment);
if (start > -1) {
// You can use the accessToken for api calls now.
String accessToken = url.substring(start + fragment.length(), url.length());
Log.v(TAG, "OAuth complete, token: [" + accessToken + "].");
Log.i(TAG, "" +accessToken);
Toast.makeText(ActivityWebView.this, "Token: " + accessToken, Toast.LENGTH_SHORT).show();
}
} …Run Code Online (Sandbox Code Playgroud) 我想在“自定义标题”栏中更改应用程序图标的大小。到目前为止,这是我的代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#000000">
<ImageView
android:id="@+id/header"
android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的styles.xml文件是:
<style name="CustomWindowTitleBackground">
<item name="android:background">#00000000</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">30dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这会在标题栏的左侧生成一个图标,但是如何更改图标的大小呢?我希望图标更大一些。
我创建了一个导航类型为"tabs + swipe"的新活动.我在getItem()方法中进行了以下更改:
@Override
public Fragment getItem(int i) {
Fragment fragment ;
switch(i){
case 0:
fragment = new Fragment1();
break;
case 1:
fragment = new Fragment2();
break;
case 3:
fragment = new Fragment3();
break;
//
default : return null;
}
//set args if necessary
//return fragment
return fragment;
}
Run Code Online (Sandbox Code Playgroud)
所以对于每个标签我都定义了一个单独的类.其中一个是这样的:
public static class Fragment1 extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public Fragment1() {
}
@Override
public View onCreateView(LayoutInflater inflater, …Run Code Online (Sandbox Code Playgroud) 如何显示应用程序崩溃(或服务崩溃)的通知,如果用户单击它,它会通过电子邮件发送StackTrace?
我看到一些应用程序这样做.