小编Pun*_*itD的帖子

使用Android SDK为Facebook登录启用Chrome自定义标签

我在我的应用程序中使用Facebook SDK版本4.11.0.

根据官方文档页面上列出的步骤,我在清单文件中添加了以下内容以启用Chrome自定义标签.

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

<activity
    android:name="com.facebook.CustomTabActivity"
    android:exported="true">
    <intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
       <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>
</activity>

<meta-data
    android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/app_id" />
Run Code Online (Sandbox Code Playgroud)

fb_login_protocol_scheme添加到strings.xml'fb + app_id'

身份验证过程正常,没有任何问题.
唯一需要关注的是当我点击登录按钮时,登录对话框不会在Chrome自定义标签中打开,而是以通常的网络视图对话框格式打开.

此处是否缺少某些内容可添加到项目中以启用Chrome自定义标签?

android facebook facebook-android-sdk facebook-sdk-4.0 chrome-custom-tabs

10
推荐指数
1
解决办法
6473
查看次数

动画工具栏和片段交易

我有使用以下xml实现Navigation Drawer的MainActivity:

<android.support.v4.widget.DrawerLayout
xmlns:android ="http://schemas.android.com/apk/res/android"
android:id ="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/container_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
    </LinearLayout>

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#FFFFFF"/>


</LinearLayout>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity ="start"
    >


    <ListView
        android:id="@+id/drawerList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="5dp"
        android:divider="@color/material_blue_grey_800"
        android:dividerHeight="1dp"
        android:background="#FFFFFF"
        />

   </RelativeLayout>

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

现在我在listview中有3个项目,点击其中任何一个项目,我的代码将Framelayout替换为如下特定片段:

Fragment f1 = new Fragment()

 FragmentTransaction ft = getSupportFragmentManager().beginTransaction()
 ft.setCustomAnimations(R.anim.slide_in,R.anim.hyper_out,R.anim.hyper_in,R.anim.slide_out)


ft.replace(R.id.content, f1).addToBackStack(null).commit();
Run Code Online (Sandbox Code Playgroud)

上面的代码可以很好地根据需要用自定义动画替换片段.但是,我的问题是如何在片段事务期间使用片段为工具栏设置动画.

所有片段都有各自的工具栏标题,这些标题在每个片段类的onActivityCreated()方法中通过以下代码进行更改:

((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("Title");
Run Code Online (Sandbox Code Playgroud)

我应该将动画应用到我的布局来掩盖工具栏吗?

animation android android-fragments

7
推荐指数
1
解决办法
888
查看次数

在Android中多次调用onPrimaryClipchanged()

我已经实现了后台服务来监听系统范围内的剪贴板事件.

服务实施:

public class ClipService extends Service {
ClipboardManager cm;

@Override
public void onCreate() {
    Log.d("FRAG","onCreate called...");
    super.onCreate();
    cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    cm.addPrimaryClipChangedListener(new ClipboardListener());
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onDestroy() {
    super.onDestroy();
    cm.removePrimaryClipChangedListener(new ClipboardListener());
}

class ClipboardListener implements ClipboardManager.OnPrimaryClipChangedListener{

     @Override
     public void onPrimaryClipChanged() {
        Log.d("FRAG","onPrimaryClipChanged called..");
        if(cm!=null) {
            String s1 = cm.getPrimaryClip().getItemAt(0).coerceToText(ClipService.this).toString();
            ContentValues cv = new ContentValues();
            cv.put(DatabaseHelper.CONTENT,s1);
            getContentResolver().insert(DataProvider.CONTENT_URI, cv);//Insert using Content provider
        }
     }
}
}
Run Code Online (Sandbox Code Playgroud)

现在我担心的是,对于复制到剪贴板的每个文本,三个条目都被插入单个复制事件...即onPrimaryClipChanged被调用三次..

我正在使用`Log.d("FRAG","onPrimaryClipChanged called .."); 并且它被记录了3次,所以问题似乎是每个剪贴板更改事件被调用3次函数而不插入部分代码. …

android

6
推荐指数
1
解决办法
878
查看次数