Android 页面跳转最简便的方法!

时间:2022-12-30 23:21:03

第一步:

 1     /**
 2      * 获取所有的Activtiy
 3      * 
 4      * @return
 5      */
 6     public static SparseArray<String> getCompanyPackageName() {
 7         String packbackName = "com.tiancheng.business.activity.";
 8         SparseArray<String> array = new SparseArray<String>();
 9         array.put(2, packbackName + "NoticeActivity");
10         array.put(3, packbackName + "ManagerInfoFriendActivity");
11         array.put(6, packbackName + "CompanyTogetherActivity");
12         array.put(11, packbackName + "ServiceNeedApplyActivity");
13         array.put(12, packbackName + "ServiceProgressSearchActivity");
14         array.put(13, packbackName + "ServiceResultScoreActivity");
15         array.put(14, packbackName + "ServiceProjectSearchActivity");
16         array.put(32, packbackName + "ServiceProjectGroupSearchActivity");
17         array.put(38, packbackName + "ComplaintListActivity");
18         array.put(39, packbackName + "PublishMessageActivity");
19         array.put(40, packbackName + "MyMessageActivity");
20         return array;
21     }

第二步:

 1 /**
 2      * 设置权限
 3      */
 4     private void setCompanyAuthority(int position) {
 5         SparseArray<String> array = Utils.getCompanyPackageName();
 6         for (int i = 0; i < array.size(); i++) {
 7             if (position == array.keyAt(i)) {
 8                 Intent intent = null;
 9                 try {
10                     intent = new Intent(this, Class.forName(array.valueAt(i)
11                             .toString()));
12                     intent.putExtra("Flag", 0);
13                     intent.putExtra("ID", 0);
14                     intent.putExtra("FWXMID", 0);
15                 } catch (ClassNotFoundException e) {
16                     e.printStackTrace();
17                 }
18                 startActivity(intent);
19             }
20         }
21     }

到此为止.....