zoukankan      html  css  js  c++  java
  • ActionBar Fragment的一个sample activity; 及获取runningAppProcess及跳转

    public class MainActivity extends ActionBarActivity {
        private static ActivityManager am;
        private static List<RunningAppProcessInfo>  appList;
        private static List<RunningTaskInfo> taskList; 
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.container, new PlaceholderFragment()).commit();
            }
            
            
            am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
            
            appList = am.getRunningAppProcesses();
            taskList = am.getRunningTasks(100);
            
            for(RunningAppProcessInfo info: appList){
                Log.d("linsen",""+info.processName);
            }
            for(RunningTaskInfo info: taskList){
                Log.i("linsen", ""+info.topActivity);
            }
            
            
        }
    
    
    
        /**
         * A placeholder fragment containing a simple view.
         */
        public static class PlaceholderFragment extends Fragment {
            private Button btn2;
            public PlaceholderFragment() {
            }
    
            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.fragment_main, container,
                        false);
                btn2  = (Button) rootView.findViewById(R.id.button1);
                btn2.setOnClickListener(new OnClickListener() {
                    
                    @SuppressLint("NewApi")
                    @Override
                    public void onClick(View v) {
                        
                        am.moveTaskToFront(taskList.get(4).id,0);
                        Log.w("linsen","btn2 onclicked");
                        moveTask();
                    }
    
                    
                });
                return rootView;
            }
        }
        private static void moveTask() {
            // TODO Auto-generated method stub
            
        }
        
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
    
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }
    
    }

     About Fragment, there are 3 import methods:     Fragment.onCreateView;     Activity.getSupportFragmentManager;  FragmentManager.beginTransaction; 

     Fragment.onCreateView;    

    Activity.getSupportFragmentManager;  

    FragmentManager.beginTransaction; 

  • 相关阅读:
    Scala In 5 Years – My Prediction « GridGain – Real Time Big Data
    牛魔王珍满福拉面 北京团购网|京东团购
    Build WebKit On Windows 白果果白的专栏 博客频道 CSDN.NET
    fabulous
    Selenimu做爬虫 oscarxie 博客园
    EA gpl
    数据挖掘与Taco Bell编程
    test cpp could not compiled on ubuntu use g++,i'll tried lateor on win platform
    How to use ActiveRecord without Rails
    svn添加新项目管理并添加到trac 知识是一种越吃越饿的粮食 ITeye技术网站
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3719303.html
Copyright © 2011-2022 走看看