public class MainActivity extends Activity {
AdView ad ;
// Declaring the ID of the HELP dialog box and the Exit dialog box
static final int EXIT_DIALOG = 0 ;
static final int HELP_DIALOG = 1 ;
// Call the options menu with one button About
Override
public boolean onCreateOptionsMenu ( Menu menu ) {
MenuInflater inflater = getMenuInflater ( ) ;
inflater. inflate ( R. menu . gameoptions , menu ) ;
menu. findItem ( R. id . about_menu_item ) ;
menu. findItem ( R. id . btn_email ) ;
return true ;
}
// processing clicks on the options menu items
// Call the HELP dialog from the options menu when you click on "About the application" and go to EmailActivity when you click on "contact us"
Override
public boolean onOptionsItemSelected ( MenuItem item ) {
switch ( item. getItemId ( ) ) {
case R. id . about_menu_item :
showDialog ( HELP_DIALOG ) ;
return true ;
case R. id . btn_email :
startActivity ( new Intent ( getApplicationContext ( ) , EmailActivity. class ) ) ;
return true ;
default :
return super . onOptionsItemSelected ( item ) ;
}
}
/ ** Called when the activity is first created. * /
Override
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState ) ;
requestWindowFeature ( Window . FEATURE_NO_TITLE ) ; // hide the title
setContentView ( R. layout . second ) ;
// connect advertising
// Get the view
ad = ( AdView ) findViewById ( R. id . ad ) ;
ad. onDebug = true ;
// Install event listeners
// callback - the listener, through which you can get information
// about events in the library. The following listeners are still available: AdLoaded, AdClickThru
// and AdStopped. To initialize, you must pass the environmentVars parameter,
// which contains information about the registered site in the system
// (BEGUN_PAD_ID, BEGUN_BLOCK_ID).
// To start initialization, call the ad.init method. Then wait
// callback with adLoaded status and only then call the method
// ad.api ("initAd", al);
ad. setOnApiListener ( new Callback ( ) {
Override
public void init ( ) {
Log d ( "BEGUN_AD" , "ad.api | initAd" ) ;
ArrayList < RequestParam > al = new ArrayList < RequestParam > ( ) ;
RequestParam rp = new RequestParam ( ) ;
rp. name = "environmentVars" ;
rp. value = "pad_id: 261629112 | block_id: 261629500" ;
al. add ( rp ) ;
ad. api ( "initAd" , al ) ;
Log d ( "BEGUN_AD" , "CALLBACK params:" + al. toString ( ) ) ;
}
Override
public void callback ( String c ) {
Log d ( "BEGUN_AD" , "CALLBACK API:" + c ) ;
if ( c. equals ( "AdLoaded" ) ) {
Log d ( "BEGUN_AD" , "startAd" + c ) ;
ad. api ( "startAd" ) ;
}
}
} ) ;
Log d ( "BEGUN_AD" , "ad.init" ) ;
ad. init ( ) ;
// Run MatanActivity
Button b = ( Button ) this . findViewById ( R. id . btn_mathan ) ;
b. setOnClickListener ( new OnClickListener ( ) {
public void onClick ( View arg0 ) {
startActivity ( new Intent ( getApplicationContext ( ) , MatanActivity. class ) ) ;
}
} ) ;
// Start GeomActivity
Button d = ( Button ) this . findViewById ( R. id . btn_geom ) ;
d. setOnClickListener ( new OnClickListener ( ) {
public void onClick ( View arg0 ) {
startActivity ( new Intent ( getApplicationContext ( ) , GeomActivity. class ) ) ;
}
} ) ;
// Run TerverActivity
Button c = ( Button ) this . findViewById ( R. id . btn_terver ) ;
c. setOnClickListener ( new OnClickListener ( ) {
public void onClick ( View arg0 ) {
startActivity ( new Intent ( getApplicationContext ( ) , TerverActivity. class ) ) ;
}
} ) ;
}
protected void onRestart ( ) {
// TODO Auto-generated method stub
super . onRestart ( ) ;
Log d ( "BEGUN_AD" , "resumeAd" ) ;
ad. api ( "resumeAd" ) ;
}
// Create dialogs HELP_DIALOG and EXIT_DIALOG
Override
protected Dialog onCreateDialog ( int id )
{
switch ( id )
{
case HELP_DIALOG :
LayoutInflater inflater = ( LayoutInflater ) getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ;
View layout = inflater. inflate ( R. layout . help ,
( ViewGroup ) findViewById ( R. id . Root ) ) ;
AlertDialog. Builder builder = new AlertDialog. Builder ( this ) ;
builder. setView ( layout )
. setCancelable ( true )
. setTitle ( "About Application" )
. setNeutralButton ( "OK" , new DialogInterface. OnClickListener ( )
{
public void onClick ( DialogInterface dialog, int id )
{
dialog. cancel ( ) ;
}
} ) ;
AlertDialog alert = builder. create ( ) ;
return builder. create ( ) ;
case EXIT_DIALOG :
AlertDialog. Builder builder3 = new AlertDialog. Builder ( this ) ;
builder3. setMessage ( "Sure you want to quit?" )
. setCancelable ( false )
. setPositiveButton ( "Yes" , new DialogInterface. OnClickListener ( ) {
public void onClick ( DialogInterface dialog, int id ) {
SecondActivity. this . finish ( ) ;
}
} )
. setNegativeButton ( "No" , new DialogInterface. OnClickListener ( ) {
public void onClick ( DialogInterface dialog, int id ) {
dialog. cancel ( ) ;
}
} ) ;
AlertDialog alert3 = builder3. create ( ) ;
return builder3. create ( ) ;
default :
return null ;
}
}
// Call the dialogue EXIT_DIALOG when pressing the back key of the smartphone
Override
public void onBackPressed ( ) {
showDialog ( EXIT_DIALOG ) ;
}
}
<en.begun.adlib.AdView
android: id = "@ + id / ad"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: layout_alignParentBottom = "true"
/>
<uses-permission android: name = "android.permission.INTERNET" />
<uses-permission android: name = "android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android: name = "android.permission.READ_PHONE_STATE" />
import ru.begun.adlib.AdView ;
import ru.begun.adlib.Callback ;
import ru.begun.adlib.RequestParam ;
AdView ad ;
// Get the view
ad = ( AdView ) findViewById ( R. id . ad ) ;
// Install event listeners
// callback - the listener, through which you can get information
// about events in the library. The following listeners are still available: AdLoaded, AdClickThru
// and AdStopped. To initialize, you must pass the environmentVars parameter,
// which contains information about the registered site in the system
// (BEGUN_PAD_ID, BEGUN_BLOCK_ID).
// To start initialization, call the ad.init method. Then wait
// callback with adLoaded status and only then call the method
// ad.api ("initAd", al);
ad. setOnApiListener ( new Callback ( ) {
Override
public void init ( ) {
ArrayList < RequestParam > al = new ArrayList < RequestParam > ( ) ;
RequestParam rp = new RequestParam ( ) ;
rp. name = "environmentVars" ;
rp. value = "pad_id: <BEGUN_PAD_ID> | block_id: <BEGUN_BLOCK_ID>" ;
al. add ( rp ) ;
ad. api ( "initAd" , al ) ;
}
Override
public void callback ( String c ) {
if ( c. equals ( "AdLoaded" ) ) {
ad. api ( "startAd" ) ;
}
}
} ) ;
ad. init ( ) ;
<? xml version = "1.0" encoding = "utf-8" ?>
<RelativeLayout xmlns: android = " schemas.android.com/apk/res/android"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: weightSum = "1"
android: background = "@ drawable / main_1" >
<Button
android: id = "@ + id / btn1"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: background = "@ layout / button_selector_leftcorner" />
<Button android: textStyle = "bold" android: textColor = "# FFC000" android: background = "@ layout / button_selector" android: layout_height = "wrap_content" android: layout_width = "173dp" android: text = "An. Geometry and lin. algebra " android: id = " @ + id / btn_geom " android: layout_above = " @ + id / btn_terver " android: layout_alignLeft = " @ + id / btn_terver " android: layout_marginBottom = " 16dp " > </ Button >
<Button android: textStyle = "bold" android: textColor = "# FFC000" android: background = "@ layout / button_selector" android: layout_height = "wrap_content" android: layout_width = "173dp" android: text = "Mathematical analysis" android : id = "@ + id / btn_mathan" android: layout_above = "@ + id / btn_geom" android: layout_alignLeft = "@ + id / btn_geom" android: layout_marginBottom = "15dp" > </ Button >
<Button android: textStyle = "bold" android: textColor = "# FFC000" android: background = "@ layout / button_selector" android: layout_height = "wrap_content" android: layout_width = "173dp" android: text = "Probability Theory" android : id = "@ + id / btn_terver" android: layout_alignParentBottom = "true" android: layout_centerHorizontal = "true" android: layout_marginBottom = "186dp" > </ Button >
<ImageView android: id = "@ + id / imageView1" android: src = "@ drawable / andro" android: layout_height = "wrap_content" android: layout_width = "wrap_content" android: layout_above = "+ + id / btn_mathan" android: layout_centerHorizontal = "true" > </ ImageView >
<RelativeLayout android: layout_height = "wrap_content" android: layout_width = "fill_parent" >
<ImageView android: id = "@ + id / imageView2" android: layout_height = "wrap_content" android: layout_width = "wrap_content" android: src = "@ drawable / title" android: layout_alignParentTop = "true" android: layout_centerHorizontal = "true " android: layout_marginTop = " 18dp " > </ ImageView >
</ RelativeLayout >
<en.begun.adlib.AdView
android: id = "@ + id / ad"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: layout_alignParentBottom = "true"
/>
<ImageView
android: id = "@ + id / splashscreen"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: src = "@ drawable / splashscreen" android: background = "# 000" >
</ ImageView >
</ RelativeLayout >
WebView myWebView = ( WebView ) findViewById ( R. id . Webview ) ;
String summary = "<html> <body>" + text + "</ body> </ html>" ;
myWebView. loadData ( summary, "text / html" , "utf-8" ) ; // upload text to webview
WebView myWebView = ( WebView ) findViewById ( R. id . Webview ) ;
String summary = "<html> <body>" + text + "</ body> </ html>" ;
myWebView. loadDataWithBaseURL ( "x-data: // base" , summary, "text / html" , "utf-8" , null ) ;
public class EmailActivity extends Activity {
Button send ;
EditText address, subject, emailtext ;
Override
public void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState ) ;
requestWindowFeature ( Window . FEATURE_NO_TITLE ) ; // hide the title
setContentView ( R. layout . email ) ;
Button b = ( Button ) this . findViewById ( R. id . btn_market ) ;
b. setOnClickListener ( new OnClickListener ( ) {
public void onClick ( View arg0 ) {
Uri address = Uri. parse ( " market.android.com/details?id=com.mathhelper.math" ) ;
Intent surf = new Intent ( Intent. ACTION_VIEW , address ) ;
startActivity ( surf ) ;
}
} ) ;
// Our fields and button
send = ( Button ) findViewById ( R. id . emailsendbutton ) ;
address = ( EditText ) findViewById ( R. id . emailaddress ) ;
// subject = (EditText) findViewById (R.id.emailsubject);
emailtext = ( EditText ) findViewById ( R. id . emailtext ) ;
send. setOnClickListener ( new OnClickListener ( ) {
Override
public void onClick ( View v ) {
final Intent emailIntent = new Intent ( android. content . Intent . ACTION_SEND ) ;
emailIntent. setType ( "plain / text" ) ;
// To
emailIntent. putExtra ( android. content . Intent . EXTRA_EMAIL , new String [ ] { address. getText ( ) . toString ( ) } ) ;
// About what
emailIntent. putExtra ( android. content . Intent . EXTRA_TEXT , emailtext. getText ( ) . toString ( ) ) ;
EmailActivity. this . startActivity ( Intent. createChooser ( emailIntent,
"Sending a letter" ) ) ;
}
} ) ;
}
}
<? xml version = "1.0" encoding = "utf-8" ?>
<RelativeLayout xmlns: android = " schemas.android.com/apk/res/android"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: weightSum = "1" >
<ScrollView
android: scrollbars = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent" >
<LinearLayout android: orientation = "vertical" android: id = "@ + id / linearLayout2" android: background = "@ drawable / metall" android: layout_alignParentTop = "true" android: layout_alignParentLeft = "true" android: layout_marginTop = "40dp " android: layout_width = " fill_parent " android: layout_height = " 197dp " >
<TextView android: layout_width = "wrap_content" android: text = "Write to us:" android: layout_height = "wrap_content" android: id = "@ + id / textView1" android: gravity = "left" android: textSize = " 10pt " android: textStyle = "normal" > </ TextView >
<EditText android: id = "@ + id / emailaddress" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "svdsoftware@gmail.com" > </ EditText >
<EditText android: id = "@ + id / emailtext" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "Your Feedback ..." > </ EditText >
<RelativeLayout android: layout_height = "wrap_content" android: layout_width = "fill_parent" android: id = "@ + id / relativeLayout1" >
<TextView android: id = "@ + id / textView1" android: text = "Send us an email →" android: layout_width = "wrap_content" android: gravity = "left" android: layout_height = "wrap_content" android: textSize = "9pt " android: textStyle = " normal " android: layout_centerVertical = " true " > </ TextView >
<Button android: id = "@ + id / emailsendbutton" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: background = "@ layout / button_selector_email" android: layout_alignParentTop = "true" android: layout_alignParentRight = "true " > </ Button >
</ RelativeLayout >
<RelativeLayout android: id = "@ + id / relativeLayout2" android: layout_height = "wrap_content" android: layout_width = "fill_parent" >
<Button android: id = "@ + id / btn_market" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: background = "@ layout / button_selector_am" android: layout_alignParentTop = "true" android: layout_alignParentRight = "true " > </ Button >
<TextView android: id = "@ + id / textView1" android: text = "Rate on the market →" android: layout_width = "wrap_content" android: gravity = "left" android: layout_height = "wrap_content" android: textSize = "9pt " android: textStyle = " normal " android: layout_centerVertical = " true " > </ TextView >
</ RelativeLayout >
</ LinearLayout >
</ ScrollView >
</ RelativeLayout >
Source: https://habr.com/ru/post/131650/
All Articles