1
1
package com .jingewenku .abrahamcaijin .commonutil ;
2
2
3
3
import android .app .Activity ;
4
- import android .content .ActivityNotFoundException ;
5
4
import android .content .Intent ;
6
- import android .os .Bundle ;
7
- import android .util .Log ;
8
5
9
- import java .io .Serializable ;
10
6
import java .util .HashMap ;
11
7
import java .util .Iterator ;
12
8
import java .util .Map .Entry ;
13
- import java .util .Set ;
14
9
15
10
/**
16
11
* 主要功能:管理Activity跳转
@@ -32,11 +27,8 @@ public AppActivitySkipUtil() {
32
27
33
28
/**
34
29
* 功能描述:简单地Activity的跳转(不携带任何数据)
35
- *
36
- * @param activity
37
- * 发起跳转的Activity实例
38
- * @param TargetActivity
39
- * 目标Activity实例
30
+ * @param activity 发起跳转的Activity实例
31
+ * @param cls 目标Activity实例
40
32
*/
41
33
public static void skipAnotherActivity (Activity activity ,
42
34
Class <? extends Activity > cls ) {
@@ -93,129 +85,4 @@ public static void skipAnotherActivity(Activity activity,
93
85
// activity.startActivity(intent);
94
86
// activity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
95
87
// }
96
-
97
- private static final String TAG = AppActivitySkipUtil .class .getSimpleName ();
98
- private static Intent intent ;
99
- private static final Object lock = new Object ();
100
-
101
- /**
102
- *
103
- * @Title: startActivity
104
- */
105
- public static <T > void doAction (Activity activity , Class <T > class1 ) {
106
- synchronized (lock ) {
107
- try {
108
- intent = new Intent (activity , class1 );
109
- activity .startActivity (intent );
110
- // activity.overridePendingTransition(R.anim.zoom_enter,
111
- // R.anim.zoom_exit);
112
- } catch (ActivityNotFoundException e ) {
113
- e .printStackTrace ();
114
- }
115
- }
116
-
117
- }
118
-
119
- /**
120
- *
121
- * @Title: startActivity
122
- */
123
- public static <T > void doAction (Activity activity , Class <T > class1 ,
124
- String key , Object object ) {
125
- synchronized (lock ) {
126
- try {
127
- intent = new Intent (activity , class1 );
128
- if (object != null && object instanceof String ) {
129
- intent .putExtra (key , (String ) object );
130
- } else if (object != null && object instanceof Integer ) {
131
- intent .putExtra (key , (Integer ) object );
132
- }
133
- activity .startActivity (intent );
134
- // activity.overridePendingTransition(R.anim.zoom_enter,
135
- // R.anim.zoom_exit);
136
- } catch (ActivityNotFoundException e ) {
137
- e .printStackTrace ();
138
- }
139
- }
140
-
141
- }
142
-
143
- /**
144
- *
145
- * @Title: startActivity
146
- */
147
- public static <T > void doAction (Activity activity , Class <T > class1 ,
148
- HashMap <String , Serializable > map ) {
149
- synchronized (lock ) {
150
- try {
151
- intent = new Intent (activity , class1 );
152
- if (null != map ) {
153
- Set <String > keys = map .keySet ();
154
- for (String key : keys ) {
155
- intent .putExtra (key , map .get (key ));
156
- }
157
- activity .startActivity (intent );
158
- // activity.overridePendingTransition(R.anim.zoom_enter,
159
- // R.anim.zoom_exit);
160
- }
161
- } catch (ActivityNotFoundException e ) {
162
- e .printStackTrace ();
163
- }
164
- }
165
-
166
- }
167
-
168
- /**
169
- *
170
- * @Title: startActivity
171
- */
172
- public static <T > void doAction (Activity activity , Class <T > class1 ,
173
- Bundle bundle ) {
174
- synchronized (lock ) {
175
- try {
176
- intent = new Intent (activity , class1 );
177
- if (bundle != null ) {
178
- intent .putExtras (bundle );
179
- }
180
-
181
- activity .startActivity (intent );
182
- // activity.overridePendingTransition(R.anim.zoom_enter,
183
- // R.anim.zoom_exit);
184
-
185
- } catch (ActivityNotFoundException e ) {
186
- e .printStackTrace ();
187
- }
188
- }
189
-
190
- }
191
-
192
- public static Intent getLauncherIntent () {
193
- Intent intent = new Intent (Intent .ACTION_MAIN );
194
- intent .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
195
- intent .addCategory (Intent .CATEGORY_HOME );
196
- return intent ;
197
- }
198
-
199
- public static void logIntent (String tag , Intent intent ) {
200
- if (intent == null ) {
201
- return ;
202
- }
203
- StringBuffer sb = new StringBuffer ();
204
- sb .append ("\n Action:" + intent .getAction ());
205
- sb .append ("\n Data:" + intent .getData ());
206
- sb .append ("\n DataStr:" + intent .getDataString ());
207
- sb .append ("\n Scheme:" + intent .getScheme ());
208
- sb .append ("\n Type:" + intent .getType ());
209
- Bundle extras = intent .getExtras ();
210
- if (extras != null && !extras .isEmpty ()) {
211
- for (String key : extras .keySet ()) {
212
- Object value = extras .get (key );
213
- sb .append ("\n EXTRA: {" + key + "::" + value + "}" );
214
- }
215
- } else {
216
- sb .append ("\n NO EXTRAS" );
217
- }
218
- Log .i (tag , sb .toString ());
219
- }
220
-
221
88
}
0 commit comments