package com.example.zhuanhuan
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import com.example.zhuanhuan.MainActivity
import com.example.zhuanhuan.R
import com.example.zhuanhuan.KkkActivity
import android.os.Bundle
import android.os.Environment
import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Button zhuceButton = (Button) findViewById(R.id.button2)
Button dengluButton = (Button) findViewById(R.id.button1)
final EditText yonghumingEditText = (EditText) findViewById(R.id.editText1)
final EditText mimaEditText = (EditText) findViewById(R.id.editText2)
zhuceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent()
intent.setClass(MainActivity.this, KkkActivity.class)
startActivity(intent)
}
}
dengluButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try {
FileInputStream fis = new FileInputStream(Environment.getExternalStorageDirectory().getPath()+"/"+ yonghumingEditText.getText().toString())
byte[] input = new byte[fis.available()]
while(fis.read(input) != -1 )
fis.close()
//Toast.makeText(getApplicationContext(), new String(input), Toast.LENGTH_SHORT).show()
String mimaString = new String(input)
if (mimaString.equals(mimaEditText.getText().toString())==true) {
Toast.makeText(getApplicationContext(), "成功登陆", Toast.LENGTH_SHORT).show()
Intent intent = new Intent()
intent.setClass(MainActivity.this, QqqActivity.class)
startActivity(intent)
}
else {
Toast.makeText(getApplicationContext(), "用户名或密码错误", Toast.LENGTH_SHORT).show()
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace()
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
}
})
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menuthis adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu)
return true
}
}
二、
package com.example.zhuanhuan
import java.security.PublicKey
import android.os.Bundle
import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.Toast
public class QqqActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.qqq)
Button fanhuiButton = (Button) findViewById(R.id.button2)
Button jianceButton = (Button) findViewById(R.id.button1)
jianceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_SHORT).show()
Intent new = new Intent()
intent.setClass(QqqActivity.this, MainActivity.class)
startActivity(intent)
}
})
fanhuiButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent()
intent.setClass(QqqActivity.this, AaaActivity.class)
startActivity(intent)
}
})
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menuthis adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.qqq, menu)
return true
}
}
三、
package com.example.zhuanhuan
import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import com.example.zhuanhuan.MainActivity
import com.example.zhuanhuan.R
import android.os.Bundle
import android.os.Environment
import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
import android.widget.EditText
public class KkkActivity extends Activity {
private File writeFile
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.kkk)
Button backButton = (Button) findViewById(R.id.button1)
final EditText yonghumingEditText = (EditText) findViewById(R.id.editText1)
final EditText mimaEditText = (EditText) findViewById(R.id.editText2)
backButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
File writeFile = new File(Environment.getExternalStorageDirectory().getPath(), yonghumingEditText.getText().toString())
if (!writeFile.exists()) {
try {
writeFile.createNewFile()
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
}
String abcString = mimaEditText.getText().toString()
FileOutputStream fos
try {
for = new FileOutputStream(writeFile)
fos.write(abcString.getBytes())
fos.flush()
fos.close()
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace()
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
Intent intent = new Intent()
intent.setClass(KkkActivity.this, MainActivity.class)
startActivity(intent)
}
})
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menuthis adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.kkk, menu)
return true
}
}
四、
package com.example.zhuanhuan
import android.os.Bundle
import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button
public class AaaActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.aaa)
Button jianceButton = (Button) findViewById(R.id.button1)
jianceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent()
intent.setClass(AaaActivity.this, QqqActivity.class)
startActivity(intent)
}
})
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menuthis adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.aaa, menu)
return true
}
}
最近在做一个项目,接收手机短信,获取其中的验证码,然后发给后端保存,这个功能很简单,事实上,这个功能也确实不需要什么界面,主要装了这个服务的apk就可以了。
怎么做到app没有界面呢?
对的,使用这个主题就搞定了。
为了适配6.0,需要如下 *** 作:
完结!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)