title: Error when running Android TabHost
body: <p>Hey, I'm trying to implement two tabs. Each one calls a specifig activity. But when I try to run I have this error:</p>
  
  <pre><code>12-07 20:26:22.164: ERROR/AndroidRuntime(363): FATAL EXCEPTION: main
  12-07 20:26:22.164: ERROR/AndroidRuntime(363): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.psyhclo/com.psyhclo.Main}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.psyhclo/com.psyhclo.RatedCalls}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{405a8ac8 363:com.psyhclo/10030} (pid=363, uid=10030) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.os.Handler.dispatchMessage(Handler.java:99)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.os.Looper.loop(Looper.java:123)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.main(ActivityThread.java:3647)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at java.lang.reflect.Method.invoke(Method.java:507)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at dalvik.system.NativeStart.main(Native Method)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.psyhclo/com.psyhclo.RatedCalls}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{405a8ac8 363:com.psyhclo/10030} (pid=363, uid=10030) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1462)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.widget.TabHost.addTab(TabHost.java:216)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at com.psyhclo.Main.onCreate(Main.java:17)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     ... 11 more
  12-07 20:26:22.164: ERROR/AndroidRuntime(363): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{405a8ac8 363:com.psyhclo/10030} (pid=363, uid=10030) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.os.Parcel.readException(Parcel.java:1322)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.os.Parcel.readException(Parcel.java:1276)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:1882)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.getProvider(ActivityThread.java:3311)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.acquireProvider(ActivityThread.java:3336)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1634)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.content.ContentResolver.acquireProvider(ContentResolver.java:748)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.content.ContentResolver.query(ContentResolver.java:256)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at com.psyhclo.RatedCalls.onCreate(RatedCalls.java:27)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
  12-07 20:26:22.164: ERROR/AndroidRuntime(363):     ... 20 more
  </code></pre>
  
  <p>Here is the <strong>Main.java</strong></p>
  
  <pre><code>import android.app.TabActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.widget.TabHost;
  
  public class Main extends TabActivity {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      TabHost tabHost = getTabHost();
      tabHost.addTab(tabHost.newTabSpec("one").setIndicator("Rated Calls")
              .setContent(new Intent(this, RatedCalls.class)));
      tabHost.addTab(tabHost.newTabSpec("two").setIndicator("Rated Contacts")
              .setContent(new Intent(this, SMS.class)));
  
      tabHost.setCurrentTab(2);
  
  }
  
      }
  </code></pre>
  
  <p>Here is the <strong>RatedCalls.java</strong> class</p>
  
  <pre><code>import java.text.DateFormat;
  import java.util.ArrayList;
  
  import com.psyhclo.R;
  
  import android.app.Activity;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class RatedCalls extends Activity {
  
  private static TextView txtView;
  private CallDataHelper dh;
  StringBuilder sb = new StringBuilder();
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.ratedcalls);        
  
      //txtView = (TextView) findViewById(R.id.TextView01);
      TextView txtView = new TextView(this);
      Cursor cursor = getContentResolver().query(
              android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
              android.provider.CallLog.Calls.DATE + " DESC ");
  
      startManagingCursor(cursor);
      int numberColumnId = cursor
              .getColumnIndex(android.provider.CallLog.Calls.NUMBER);
      int durationId = cursor
              .getColumnIndex(android.provider.CallLog.Calls.DURATION);
      int contactNameId = cursor
              .getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
      int dateId = cursor.getColumnIndex(android.provider.CallLog.Calls.DATE);
      int numTypeId = cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NUMBER_TYPE);
  
      ArrayList&lt;String&gt; callList = new ArrayList&lt;String&gt;();
      if (cursor.moveToFirst()) {
          do {
  
              String callerPhoneNumber = cursor.getString(numberColumnId);
              String contactName = cursor.getString(contactNameId);
              String duration = cursor.getString(durationId);
              String callDate = DateFormat.getDateInstance().format(dateId);      
              String numType = cursor.getString(numTypeId);
  
              //this.dh.insert(1, contactName, callerPhoneNumber, numType, duration, callDate, "01:20");
              Toast.makeText(getBaseContext(), "Inserted!", Toast.LENGTH_LONG);
              callList.add("\nNew Info: \nContact Number: "
                      + callerPhoneNumber + "\nContact Name: " + contactName
                      + "\nDuration: " + duration + "\nDate: " + callDate);
  
          } while (cursor.moveToNext());
      }
      txtView.setText(callList.toString());
  }
      }
  </code></pre>
  
  <p>And here is the <strong>ratedcalls.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  &lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="5dp"&gt;
      &lt;TabWidget
          android:id="@android:id/tabs"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content" /&gt;
      &lt;FrameLayout
          android:id="@android:id/tabcontent"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="5dp" /&gt;
  &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p>And here is the <strong>main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  &lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="5dp"&gt;
      &lt;TabWidget
          android:id="@android:id/tabs"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content" /&gt;
      &lt;FrameLayout
          android:id="@android:id/tabcontent"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="5dp" /&gt;
  &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>