Android Open Source - android-training-tutorial Second Activity






From Project

Back to project page android-training-tutorial.

License

The source code is released under:

MIT License

If you think the Android project android-training-tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package im.ene.dev.zbroadcastreceiver;
/* w  ww  .ja v a  2  s  .  co m*/
import im.ene.dev.zbroadcastreceiver.receivers.CustomBroadcastReceiver;
import im.ene.dev.zbroadcastreceiver.receivers.CustomBroadcastReceiver.OnBroadcastReceiveListener;
import im.ene.dev.zbroadcastreceiver.services.CustomBroadcastService;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class SecondActivity extends Activity implements OnClickListener, OnBroadcastReceiveListener {

  private Button mButton;
  private Context mContext;
  private TextView mTextView;
  private String mLatestString = "";
  
  private CustomBroadcastReceiver mReceiver;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.second_activity_view);
    
    mButton = (Button) findViewById(R.id.second_button);
    mTextView = (TextView) findViewById(R.id.second_textview);
    mTextView.setText(mLatestString);
    
    mButton.setOnClickListener(this);
    mTextView.setOnClickListener(this);
    
    mReceiver = new CustomBroadcastReceiver();
    mReceiver.setOnBroadcastReceiveListener(this);
  }

  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    registerReceiver(mReceiver, new IntentFilter(CustomBroadcastService.BROADCAST_ACTION));
  }
  
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
    case R.id.second_button:
      
      break;

    case R.id.second_textview:
      finish();
      break;
    }
  }
  
  @Override
  protected void onPause() {
    super.onPause();
    try {
      unregisterReceiver(mReceiver);
    } catch (Exception er) {
      er.printStackTrace();
    }
  }
  
  @Override
  protected void onDestroy() {
    super.onDestroy();
    finish();
  }

  @Override
  public void onBroadcastReceiveUpdateUI(Intent intent) {
    mLatestString = "SUB - " + intent.getStringExtra("text");
    mTextView.setText(mLatestString);
    
  }
}




Java Source Code List

com.flavienlaurent.vdh.DragActivity.java
com.flavienlaurent.vdh.DragLayout.java
com.flavienlaurent.vdh.HorizontalDragLayout.java
com.flavienlaurent.vdh.MainActivity.java
com.flavienlaurent.vdh.YoutubeActivity.java
com.flavienlaurent.vdh.YoutubeLayout.java
com.flavienlaurent.vdh.listener.SwipeDismissTouchListener.java
com.hb.views.PinnedSectionListView.java
fi.harism.curl.CurlActivity.java
fi.harism.curl.CurlMesh.java
fi.harism.curl.CurlPage.java
fi.harism.curl.CurlRenderer.java
fi.harism.curl.CurlView.java
im.ene.dev.zbroadcastreceiver2.MainActivity.java
im.ene.dev.zbroadcastreceiver2.receivers.CustomBroadcastReceiver.java
im.ene.dev.zbroadcastreceiver2.services.CustomBroadcastService.java
im.ene.dev.zbroadcastreceiver.MainActivity.java
im.ene.dev.zbroadcastreceiver.SecondActivity.java
im.ene.dev.zbroadcastreceiver.receivers.CustomBroadcastReceiver.java
im.ene.dev.zbroadcastreceiver.services.CustomBroadcastService.java
im.ene.dev.zserviceibinder.MainActivity.java
im.ene.dev.zserviceibinder.services.CustomService.java
im.ene.pinnedheaderlistviewsample.MainActivity.java
im.ene.samplevideoplayer.MainActivity.java
im.ene.samplevideoplayer.constant.Constant.java
im.ene.samplevideoplayer.views.CustomSurfaceView.java
im.ene.samplevideoplayer.views.VideoControllerView.java
im.ene.zaidlservicesample.MainActivity.java
im.ene.zaidlservicesample.Second.java
im.ene.zanimationsample.MainActivity.java
im.ene.zcustomvideoview.MainActivity.java
im.ene.zcustomvideoview.views.CustomVideoView.java
im.ene.zcustomvideoview.views.VideoControllerView.java
im.ene.zintenttutorial.MainActivity.java
im.ene.zintenttutorial.broadcastreceiver.CustomBroadcastReceiver.java
im.ene.zintenttutorial.services.CustomService.java
im.ene.zviewpager.MainActivity.java