我正在做一个锁定屏幕的应用程序.现在它是锁定的,如果屏幕没有进入必须打开屏幕的服务,它就从那里进入广播接收器.
以下是广播接收器:
public class ScreenReceiver extends BroadcastReceiver {
public static boolean wasScreenOn = true;
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("Entered Broadcaste Reciever");
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
// DO WHATEVER YOU NEED TO DO HERE
System.out.println("SCREEN_OFF"+wasScreenOn);
wasScreenOn = false;
Intent i = new Intent(context, UpdateService.class);
i.putExtra("screen_state", wasScreenOn);
context.startService(i);
System.out.println("jrkejhr keh");
}
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
// AND DO WHATEVER YOU NEED TO DO HERE
wasScreenOn = true;
System.out.println("SCREEN_ON"+wasScreenOn);
}
}
Run Code Online (Sandbox Code Playgroud)
它进入我写过回家的意图行动的服务是......
ShakeListener mShaker;
int amountOfTime = 0;
Context context1; …Run Code Online (Sandbox Code Playgroud) 我想将一个字节数组转换为一个图像,为此我使用了代码
final BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(decrpt));
Run Code Online (Sandbox Code Playgroud)
其中Decrypt是字节数组,它在ImageIO中显示错误.我不知道该参数是什么,请帮助我解决它.
我想以编程方式发送MMS,我使用了以下代码
Intent sendIntent1 = new Intent(Intent.ACTION_SEND);
try {
sendIntent1.setType("text/x-vcard");
sendIntent1.putExtra("address","0475223091");
sendIntent1.putExtra("sms_body","hello..");
sendIntent1.putExtra(Intent.EXTRA_STREAM,
Uri.parse(vcfFile.toURL().toString()));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
startActivity(sendIntent1);
Run Code Online (Sandbox Code Playgroud)
问题是它指向撰写消息页面,并需要手动发送短信,我不想这样,没有任何通知它应该发送我怎么能这样做?
SomeBody请与我分享答案
我想通过点击按钮停止并启动广播接收器.与广播接收器相关的两个服务也应该停止并按下按钮开始我该怎么做...
我想开发一个为呼叫播放背景音乐的应用程序,并且仅对呼叫者和听者可听见.有没有任何已经可用的应用程序,是否有可能在Android?
在我的应用程序中,我想从SD卡到特定位置获取图像,我需要在图库中显示,
我使用的代码附加
private Gallery gallery;
private ImageView imgView;
int position;
private byte[] data = { };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gridview);
try{
String filepath = "/sdcard/data/Crak/";
File imagefile = new File(filepath +"abcd.jpg" );
FileInputStream fis = new FileInputStream(imagefile);
Bitmap bi = BitmapFactory.decodeStream(fis);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
System.out.println("cnvrtn");
}
catch(Exception e) {
e.printStackTrace();
}
final Bitmap bitmapimage = BitmapFactory.decodeByteArray(data, 0, data.length);
position = 0;
imgView = (ImageView) findViewById(R.id.ImageView01);
imgView.setImageBitmap(bitmapimage);
gallery = …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我从图库中的文件夹中获取图像并将其保存到数组列表中.现在我只想提取带有.jpg扩展名的文件.我怎么能这样做
保存到数组列表的代码是
private List<String> ReadSDCard()
{
//It have to be matched with the directory in SDCard
File f = new File("sdcard/data/crak");
File[] files=f.listFiles();
for(int i=0; i<files.length; i++)
{
File file = files[i];
/*It's assumed that all file in the path are in supported type*/
tFileList.add(file.getPath());
}
return tFileList;
}
Run Code Online (Sandbox Code Playgroud)