我有一个SeekBar,它显示正确的MediaPlayer进度.但是,我遇到了麻烦 - 如果我在某处找到滚动框,它只会返回播放音频文件的位置.
public class EntityPageActivity extends Activity implements Runnable, OnClickListener, OnSeekBarChangeListener{
private SeekBar seekBar;
private Button startMedia;
private Button pauseMedia;
private MediaPlayer mp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.entity_page);
AudioControl();
}
public void AudioControl(){
seekBar = (SeekBar) findViewById(R.id.seekBar);
startMedia = (Button) findViewById(R.id.play);
pauseMedia = (Button) findViewById(R.id.pause);
startMedia.setOnClickListener(this);
pauseMedia.setOnClickListener(this);
}
public void run() {
int currentPosition= 0;
int total = mp.getDuration();
while (mp!=null && currentPosition<total) {
try {
Thread.sleep(1000);
currentPosition= mp.getCurrentPosition();
} catch (InterruptedException …Run Code Online (Sandbox Code Playgroud) 我通过这种方式绑定到服务:
活动类:
ListenLocationService mService;
@Override
public void onCreate(Bundle savedInstanceState) {
...
Intent intent = new Intent(this, ListenLocationService.class);
intent.putExtra("From", "Main");
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
...
}
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
LocalBinder binder = (LocalBinder) service;
mService = binder.getService();
}
public void onServiceDisconnected(ComponentName arg0) {
}
};
Run Code Online (Sandbox Code Playgroud)
这是onBind我服务的方法:
@Override
public IBinder onBind(Intent intent) {
Bundle extras = intent.getExtras();
if(extras == null)
Log.d("Service","null");
else
{
Log.d("Service","not null");
String from = …Run Code Online (Sandbox Code Playgroud) 我需要在Android应用程序中创建自己的工具栏.现在它看起来像这样:
所以你看到按钮之间的空格.我试图在按钮上放置负边距/填充,但空间并没有消失.
这是布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/routes_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5">
</ListView>
<TableRow
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="0dp" >
<Button
android:id="@+id/btn_routes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/routes"
android:textSize="10dp" />
<Button
android:id="@+id/btn_places"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/places" />
<Button
android:id="@+id/btn_events"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/events" />
<Button
android:id="@+id/btn_about"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/about"
android:textSize="10dp" />
</TableRow>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如何删除按钮之间的空间?
我有一组名为GreenLine1.mp3,GreenLine2.mp3等的音频文件我将把它们写成BLOB(我使用的是MS SQL Server'08),这是我的sql请求:
DECLARE @aud AS VARBINARY(MAX)
DECLARE @num AS INT
-- Load the audio data
SET @num=1
WHILE (@num<38)
BEGIN;
SELECT @aud = CAST(bulkcolumn AS VARBINARY(MAX))
FROM OPENROWSET(
BULK
'C:\Users\Ilya\folder\GreenLine' + CAST(@num AS VARCHAR) + '.mp3',
SINGLE_BLOB ) AS x
-- Insert the data to the table
INSERT INTO Mb2.dbo.Audios (Id, [Content])
SELECT NEWID(), @aud
SET @num = @num + 1
END;
Run Code Online (Sandbox Code Playgroud)
我有一个错误:'+'附近的语法不正确,期待','或')'.
如果我试着写
'C:\ Users\Ilya\folder\GreenLine'+ CAST(@num AS VARCHAR)+'.mp3'
变成一个变量并把它放在BULK之后,我在@variable,期望STRING或TEXT_LEX附近得到不正确的语法
如果我通过这种方式从Activity1启动Activity2:startActivity(Activity2);首先执行什么:onStop()(Activity1)还是onStart()(Activity2)?
他们同时或依次工作吗?如果一个接一个,什么是第一个?
所以一般来说:如果这个订单存在,第一个活动开始时第二个活动的状态顺序是什么?
如何从VS2010(C#)运行Excel宏?我使用Microsoft.Office.Interop.Excel命名空间
我有一个mp3文件作为字节数组.如何将其转回声音并使用javascript播放?
谢谢
当您使用IDE构造函数(new-> activity)创建新活动时 - 在Android Studio和Eclipse中 - 它会创建新的java文件,布局文件,向清单添加活动等.
每次TextView在布局文件中都有"Hello World"文本(如果选择"Blank Activity"模式).字符串值"Hello World"也会自动添加到字符串res文件中.
当然,不需要特别的努力来删除手动字符串值,TextView但有一天它变得非常烦人.
我的问题:
如果有办法改变新的活动创建机制并创建只是空活动布局文件(例如,只有容器布局RelativeLayout)?
我实现了简单的 SIP 客户端应用程序来接收呼叫。我浏览官方手册并从中获取代码。
我注意到
SipManager.newInstance(getApplicationContext());
Run Code Online (Sandbox Code Playgroud)
返回空值。文档称,当设备不支持 SIP API 时,就会发生这种情况。不过,我使用运行 Android 7.0 的 LG G6,并成功测试了来自 Google Play 的第三方 SIP 客户端。所以我怀疑API是否真的不受支持。我怎样才能检查呢?
我的清单具有所有权限 (INTERNET和USE_SIP)
权限USE_SIP由用户授予
我在ASP.NET中编写了Web服务,它有这样的地址:
http://localhost/RouteGen/Service.asmx
Run Code Online (Sandbox Code Playgroud)
Web Service具有Web方法GetMessage,它不接受任何参数并返回字符串.
它可以使用Web服务,我可以从其他ASP.NET应用程序甚至是Android应用程序调用它的方法.
服务器代码:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string GetMessage() {
return "Hello World";
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要GetMessage从javascript 调用web方法.
html页面:(这个网页与网络服务代码没有任何联系,它完全是另一个项目!你可以认为它是用win记事本写的)
...
<body id="body1" onload="initialize()" style="behavior:url(webservice.htc)">
</body>
...
Run Code Online (Sandbox Code Playgroud)
在我调用的initialize()方法中:
...
service_init();
processResult();
Run Code Online (Sandbox Code Playgroud)
还有这个功能:
function service_init()
{
body1.useService("http://localhost/RouteGen/Service.asmx?WSDL","TheService");
body1.TheService.callService("GetMessage");
}
function processResult(result)
{
alert(result);
}
Run Code Online (Sandbox Code Playgroud)
所以我有点:
1)在IE中processResult()返回"undefined"
2)在Chrome和FireFox中它根本不起作用(在useService之后没有出现简单警报)
问题在哪里?如何使javascript正常调用web方法并从不同的浏览器调用?