예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate()");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sms_view);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    if (getIntent() != null && getIntent().getExtras() != null) {

      int notificationId = getIntent().getExtras().getInt(SmsReceiver.EXTRA_NOTIFICATION_ID, -1);
      if (notificationId != -1) {
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.cancel(notificationId);
      }
      mPhoneNumber = getIntent().getExtras().getString(EXTRA_PHONE_NUMBER);

      setUpActionBar();
      String message = getIntent().getExtras().getString(EXTRA_MESSAGE);
      SmsUtils.markSmsAsRead(this, mPhoneNumber, message);

      mConversationListView = (ListView) findViewById(R.id.conversationList);
      mConversationAdapter = new ConversationAdapter(this, null, false);
      mConversationListView.setAdapter(mConversationAdapter);
      getSupportLoaderManager().restartLoader(0, null, this);
    } else {
      finish();
    }
  }
예제 #2
0
  private void setUpActionBar() {
    if (SmsUtils.isKnownNumber(mPhoneNumber)) {
      getSupportActionBar()
          .setTitle(ContentManager.getInstance().getContactsMap().get(mPhoneNumber));
      getSupportActionBar().setSubtitle(mPhoneNumber);
    } else {
      getSupportActionBar().setTitle(mPhoneNumber);
    }

    new Thread() {
      @Override
      public void run() {
        String title = SmsUtils.getContactName(SmsViewActivity.this, mPhoneNumber);
        if (!SmsUtils.isNullOrEmpty(title)) {
          getSupportActionBar().setTitle(title);
          getSupportActionBar().setSubtitle(mPhoneNumber);
        }
      }
    }.start();
  }