Home | History | Annotate | Download | only in exchange
      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 
     18 package com.android.exchange;
     19 
     20 import android.app.Activity;
     21 import android.content.ActivityNotFoundException;
     22 import android.content.Intent;
     23 import android.os.Bundle;
     24 import android.widget.Toast;
     25 
     26 import com.android.emailcommon.utility.IntentUtilities;
     27 
     28 /**
     29  * An empty {@link Activity} that simply redirects to the proper settings editor for the Email
     30  * application.
     31  * This is needed since the Exchange service runs as a separate UID and is therefore tracked as
     32  * a separate entity in the framework for things such as data usage. Links from those places to
     33  * Exchange should really go to Email where the real settings are.
     34  */
     35 public class SettingsRedirector extends Activity {
     36 
     37     @Override
     38     protected void onCreate(Bundle savedInstanceState) {
     39         super.onCreate(savedInstanceState);
     40         Intent redirect = new Intent(
     41                 Intent.ACTION_EDIT,
     42                 IntentUtilities.createActivityIntentUrlBuilder(IntentUtilities.PATH_SETTINGS)
     43                         .build());
     44         redirect.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
     45         try {
     46             startActivity(redirect);
     47         } catch (ActivityNotFoundException e) {
     48             Toast toast = Toast.makeText(this, R.string.email_settings_not_available,
     49                     Toast.LENGTH_SHORT);
     50             toast.show();
     51         }
     52         finish();
     53     }
     54 }
     55