按下浮动按钮打开Goog​​le驱动器应用程序

时间:2016-04-25 06:56:15

标签: java android android-intent google-drive-api google-drive-android-api

我在片段中有一个按钮,当我按下它时会打开这个屏幕,这是Google驱动器屏幕。换句话说,它只是简单地打开谷歌硬盘。

enter image description here

但我需要的是这个屏幕,你可以清楚地看到按下浮动按钮或加号按钮。

enter image description here

这是我的java文件代码

public class ThreeFragment extends Fragment{
    public ThreeFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_three, container, false);

        Button b1 = (Button) rootView.findViewById(R.id.managecloud);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_LAUNCHER);
                intent.setComponent(new ComponentName("com.google.android.apps.docs",
                        "com.google.android.apps.docs.app.NewMainProxyActivity"));
                try {
                    startActivity(intent);
                }catch (Exception e){
                    Toast.makeText(getContext(), "Error: "+e, Toast.LENGTH_LONG).show();
                }
            }
        });
        return rootView;
    }

}

0 个答案:

没有答案