我已经MUSIC_PLAYER在我的应用程序中使用了这样开始:
Intent myint = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(myint);
Run Code Online (Sandbox Code Playgroud)
我想暂停这个播放器.我怎么做?
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Thread mtr = new Thread(){
public void run()
{
try {
Intent myint = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(myint);
sleep(50000);
// Here I want to pause my application after those 50 seconds.
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
Intent myint = new Intent("nextscreen");
startActivity(myint);
}
} …Run Code Online (Sandbox Code Playgroud) 我试图将我捕获的快照放在图像视图中.对于像nexus 7和sony xperiac这样的大型设备,它正在捕捉,但图像甚至不显示,我可以看到RESULT_OK,通过设置标志位那我现在该怎么办?
package gatesapps.blogspot.com;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Random;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
String mCurrentPhotoPath;// for photo path
ImageView mImageView;
static boolean flag=false;
TextView tv;
Button test;
static final int REQUEST_TAKE_PHOTO = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用java创建一个http get请求,当我执行代码时,我正在获取403 forbidden代码.有没有办法摆脱它?我的代码是
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.*;
public class Http {
private final String USER_AGENT = "Mozilla/5.0";
public static void main(String [] args){
Http http=new Http();
try {
http.get();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void get() throws Exception{
URL ob=new URL("http://www.google.com/search?q=vamsi");
HttpURLConnection con=(HttpURLConnection) ob.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("USER_AGENT", USER_AGENT);
int responseCode=con.getResponseCode();
System.out.println("Response code is "+responseCode);
BufferedReader buf=new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
StringBuffer response =new StringBuffer();
while((input=buf.readLine())!=null){
response.append(input);
}
buf.close(); …Run Code Online (Sandbox Code Playgroud) 我发现这个有趣的事实,解释似乎是工作的罚款python ex1.txt,但它应该是ex1.py.这可能是什么原因?是否有关于此类行为的任何文档.ex1.py或ex1.txt具有相同的print "hello",如果我有任何代码更改,这将更改.什么条件python ex1.txt可能不起作用.我用Google搜索并发现没什么好处.