我必须检查设置中是否启用了系统锁定.
我使用下面的行代码
boolean b = android.provider.Settings.System.getInt(
getContentResolver(),Settings.System.LOCK_PATTERN_ENABLED, 0)==1;
Run Code Online (Sandbox Code Playgroud)
如果我设置了pattern锁,则返回true,如果设置了密码,则返回false pin/password.
我需要检查锁是否已启用它是否pattern/pin/password锁定设置.
我的代码只能pattern锁定不pin/password锁定.
所以请告诉我如何检查所有类型的锁.
我想直播视频,它是m3u8格式.所以我尝试了下面的代码
public class StreamingPlayer extends Activity implements
OnBufferingUpdateListener, OnCompletionListener,
OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback{
private static final String TAG = StreamingPlayer.class.getSimpleName();
private int mVideoWidth;
private int mVideoHeight;
private MediaPlayer mMediaPlayer;
private SurfaceView mPreview;
private SurfaceHolder holder;
private String path;
private boolean mIsVideoSizeKnown = false;
private boolean mIsVideoReadyToBePlayed = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mediaplayer_2);
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
private void playVideo() {
doCleanUp();
try {
/*
* TODO: …Run Code Online (Sandbox Code Playgroud) 我试图知道当被叫者举起电话时如何提醒.我已经使用PhoneStateListener 沿BroadcastReceiver.
一般来说它有三种状态CALL_STATE_IDLE , CALL_STATE_OFFHOOK, CALL_STATE_RINGING.
CALL_STATE_OFFHOOK 当呼叫连接时状态正在呼叫,在被呼叫者应答呼叫之后没有呼叫上述三种状态的状态.
这是我的BroadcastReceiver.
public class PhoneStateBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE);
}
public class CustomPhoneStateListener extends PhoneStateListener
{
Context context; //Context to make Toast if required
ActivityManager activityManager;
public CustomPhoneStateListener(Context context)
{
super();
this.context = context;
}
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
super.onCallStateChanged(state, incomingNumber);
Log.v("PhoneStateBroadcastReceiver", "onCallStateChanged state"+state);
switch (state)
{
case TelephonyManager.CALL_STATE_IDLE: …Run Code Online (Sandbox Code Playgroud) 我想从网址下载pdf文件.为了查看pdf文件,我使用了以下代码.
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this, "No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
它正在工作,但我如何从URL(例如http://.../example.pdf)获取pdf文件.我想从这个网址下载 pdf文件.请帮我.提前致谢.
我想让一个按钮不可见,当我点击另一个按钮时,隐形按钮将变为可见,然后onClick()对可见按钮执行操作.
onClick()我可以在可见按钮上使用什么操作.我用这个方法如下所示:
donebutton = (Button) findViewById(R.id.done);
donebutton.setOnClickListener(this);
donebutton.setVisibility(View.INVISIBLE);
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.equals(remove))
{
donebutton.setVisibility(View.VISIBLE);
}
if(v.equals(donebutton))
{
Intent i=new Intent(One.this,Second.class);
startActivity(i);
finish();
donebutton.setVisibility(View.INVISIBLE);
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的方法中,隐形和可见属性正在工作,但onClick()操作不起作用.所以请告诉我上述问题的答案,或告诉我是否有任何其他方法可见和隐藏按钮上的按钮和onclick操作.
我也用过这个方法:
done.setClickable(true);
done.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent i=new Intent(One.this,Second.class);
startActivity(i);
finish();
}
});
Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,用户可以与他/她的Facebook好友分享消息.我正在使用Facebook API for android.我可以验证用户身份,以及我可以将我的朋友列表作为Facebook用户并在墙上发布消息,但我正在寻找向我的朋友发送私人消息,我没有得到任何解决方案,所以任何身体可以帮助我,我怎样才能实现......
提前致谢
最好的祝福
我想将图像复制到剪贴板中以获得所有级别的api.为此,我从以下链接中找到了答案
http://developer.android.com/guide/topics/text/copy-paste.html
但它确实支持来自api级别11.但是我想在较低版本(低于api级别11)中执行相同的功能.ClipboardManager正在使用所有版本,但ClipData, ClipData.Item, and ClipDescription不适用于较低版本.
那么有没有办法将图像复制到剪贴板.
而且我还想从我的应用程序中复制图像并将其粘贴到另一个应用程序中,例如撰写邮件.可能吗?
最好的祝福
我在设置网址图像到图像视图时遇到问题.我试过以下方法
方法1:
Bitmap bimage= getBitmapFromURL(bannerpath);
image.setImageBitmap(bimage);
public static Bitmap getBitmapFromURL(String src) {
try {
Log.e("src",src);
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
Log.e("Bitmap","returned");
return myBitmap;
} catch (IOException e) {
e.printStackTrace();
Log.e("Exception",e.getMessage());
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
方法2:
Drawable drawable = LoadImageFromWebOperations(bannerpath);
image.setImageDrawable(drawable);
private Drawable LoadImageFromWebOperations(String url)
{
try
{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
}catch (Exception …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中显示选项卡但默认情况下在android之间的选项卡中有这样的分隔线
Tab1 | Tab2 | Tab3 |
Run Code Online (Sandbox Code Playgroud)
但我想显示这样的标签
Tab1 Tab2 Tab3
Run Code Online (Sandbox Code Playgroud)
所以我想删除两个标签之间的分隔线,默认情况下标签背景颜色是灰色.所以我想把它变成黑色.
请告诉我们如何删除两个选项卡之间的分隔线并更改选项卡的背景颜色.
提前致谢.
最好的祝福.
在我的应用程序中,我录制了一段视频然后播放.为了录制视频,我使用了以下代码
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
File MyMedia=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),"Directory");
mediaRecorder.setOutputFile(MyMedia.getAbsolutePath()+"/filename.mp4");
Run Code Online (Sandbox Code Playgroud)
它工作正常,但与本机录像机录制的另一个视频相比,视频清晰度有点低.请告诉我如何设置与本机录像机相同的视频清晰度的解决方案.