Home | History | Annotate | Download | only in widget
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.browser.widget;
     18 
     19 import com.android.browser.BrowserActivity;
     20 
     21 import android.content.BroadcastReceiver;
     22 import android.content.Context;
     23 import android.content.Intent;
     24 import android.util.Log;
     25 
     26 public class BookmarkWidgetProxy extends BroadcastReceiver {
     27 
     28     private static final String TAG = "BookmarkWidgetProxy";
     29 
     30     @Override
     31     public void onReceive(Context context, Intent intent) {
     32         if (BookmarkThumbnailWidgetService.ACTION_CHANGE_FOLDER.equals(intent.getAction())) {
     33             BookmarkThumbnailWidgetService.changeFolder(context, intent);
     34         } else if (BrowserActivity.ACTION_SHOW_BROWSER.equals(intent.getAction())) {
     35             startActivity(context,
     36                     new Intent(BrowserActivity.ACTION_SHOW_BROWSER,
     37                     null, context, BrowserActivity.class));
     38         } else {
     39             Intent view = new Intent(intent);
     40             view.setComponent(null);
     41             startActivity(context, view);
     42         }
     43     }
     44 
     45     void startActivity(Context context, Intent intent) {
     46         try {
     47             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     48             context.startActivity(intent);
     49         } catch (Exception e) {
     50             Log.w(TAG, "Failed to start intent activity", e);
     51         }
     52     }
     53 }
     54