<repo_name>VisualGMQ/Android<file_sep>/ContainerProvider/app/src/main/java/com/example/visualgmq/containerprovider/MainActivity.java
package com.example.visualgmq.containerprovider;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button diabutton = (Button)findViewById(R.id.dialbutton);
        diabutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(ActivityCompat.checkSelfPermission(MainActivity.this,"android.permission.CALL_PHONE") != PackageManager.PERMISSION_GRANTED)
                    ActivityCompat.requestPermissions(MainActivity.this,new String[]{"android.permission.CALL_PHONE"},1);
                else
                    call();
            }
        });
    }

    private void call(){
        try {
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:17355481727"));
            startActivity(intent);
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode,String[] permission,int[] grantResults){
        if(requestCode == 1)
            if(permission.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
                call();
            }else{
                Toast.makeText(MainActivity.this,"the permission haven't got",Toast.LENGTH_LONG);
            }
    }
}
<file_sep>/BoardCast/app/src/main/java/com/example/visualgmq/boardcast/MainActivity.java
package com.example.visualgmq.boardcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class MainActivity extends AppCompatActivity {

    private IntentFilter intentFilter1,intentFilter2;
    private NetworkChangeBC networkChangeBC;
    private SelfReceiver selfReceiver;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent("com.self.action.SELF_BC");
                sendBroadcast(intent);
            }
        });

        networkChangeBC = new NetworkChangeBC();
        intentFilter1 = new IntentFilter();
        intentFilter1.addAction("android.net.conn.CONNECTIVITY_CHANGE");
        registerReceiver(networkChangeBC,intentFilter1);

        intentFilter2 = new IntentFilter();
        intentFilter2.addAction("com.self.action.SELF_BC");
        selfReceiver = new SelfReceiver();
        registerReceiver(selfReceiver,intentFilter2);
    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        unregisterReceiver(networkChangeBC);
        unregisterReceiver(selfReceiver);
    }

    class NetworkChangeBC extends BroadcastReceiver{
        @Override
        public void onReceive(Context context, Intent intent){
            ConnectivityManager connectionManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
            NetworkInfo networkinfo = connectionManager.getActiveNetworkInfo();
            if(networkinfo!=null)
                if(networkinfo.isAvailable())
                    Toast.makeText(context,"the Network is available!",Toast.LENGTH_SHORT).show();
                else
                    Toast.makeText(context,"the Network is not avaliable!",Toast.LENGTH_SHORT).show();

        }
    }


   class SelfReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO: This method is called when the BroadcastReceiver is receiving
            // an Intent broadcast.
            Toast.makeText(context,"I have received the BroadCast",Toast.LENGTH_LONG).show();
        }
    }
}
<file_sep>/FileIO/app/src/main/java/com/example/visualgmq/fileio/MainActivity.java
package com.example.visualgmq.fileio;

import android.content.SharedPreferences.Editor;
import android.content.*;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
import java.io.*;
import java.sql.BatchUpdateException;
import java.util.*;

import java.io.FileOutputStream;

public class MainActivity extends AppCompatActivity {

    private FileOutputStream fos;
    private FileInputStream ios;
    private BufferedWriter bw;
    private BufferedReader br;
    private String text;

    @Override
    //use simple file.
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button obutton1 = (Button)findViewById(R.id.obutton1);
        obutton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    ios = openFileInput("test.txt");
                    br = new BufferedReader(new InputStreamReader(ios));
                    Toast.makeText(MainActivity.this,br.readLine(),Toast.LENGTH_LONG).show();
                    br.close();
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
        });

        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    fos = openFileOutput("test.txt", Context.MODE_PRIVATE);
                    bw = new BufferedWriter(new OutputStreamWriter(fos));
                    EditText et = (EditText)findViewById(R.id.edittext);
                    text = et.getText().toString();
                    bw.write(text);
                    bw.close();
                    Toast.makeText(MainActivity.this,"the text has saved",Toast.LENGTH_SHORT).show();
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
        });

        Button bnext = (Button)findViewById(R.id.buttonnext);
        bnext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,PrepActivity.class);
                startActivity(intent);
            }
        });
    }
}