我有两个应用程序与两个不同的数据短信广播,我想在它们两个接收数据短信.为此,我在每个应用程序中创建了广播
应用1中的接收器1:
<receiver android:name=".SMSReceiver" >
<intent-filter android:priority="10" >
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
<data android:scheme="sms" />
<data android:port="5555" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
应用程序二中的接收者两个:
<receiver android:name=".SMSReceiver1" >
<intent-filter android:priority="10" >
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
<data android:scheme="sms" />
<data android:port="8901" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
现在的情况是这样,短信只在第一个安装的应用程序中收到,我尝试过相同的端口,类名和不同的.但问题没解决,怎么解决呢?这是我的广播接收器类
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle myBundle = intent.getExtras();
SmsMessage[] messages = null;
String strMessage = "";
byte[] data = null;
if (myBundle != null) {
Object[] pdus = (Object[]) myBundle.get("pdus");
messages = …Run Code Online (Sandbox Code Playgroud) 我试图在linearlayout中设置webview.我刚刚在线性布局中创建了一个xml线性布局文件,进度条和webview.
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
android:id="@+id/progWeb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:max="100"
android:visibility="invisible" />
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
和java文件只显示进度条.此代码未显示Webview
public class MainActivity extends Activity {
private WebView web;
private ProgressBar progBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.web);
progBar = (ProgressBar) findViewById(R.id.progWeb);
progBar.setVisibility(ProgressBar.INVISIBLE);
String url = "http://www.google.com.pk/";
web.getSettings().setJavaScriptEnabled(true);
web.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
System.out.println(progress);
progBar.setProgress(progress);
if (progress == 100) {
progBar.setVisibility(ProgressBar.INVISIBLE);
progBar.setProgress(0);
} …Run Code Online (Sandbox Code Playgroud) 我有两个类如下
public class A{
private static class B{
private static int s1;
private static int s2;
private int x;
}
}
Run Code Online (Sandbox Code Playgroud)
在 B 类中,所有字段都是私有的,并且这些所有字段都不应在 A 类中访问。但是存在一个“谜团”,即 A 类中可以访问静态字段
private int x
Run Code Online (Sandbox Code Playgroud)
不可访问。我的问题是为什么可以在 A 类中访问私有静态字段?
注意:我的 B 类是静态的,它的构造函数是私有的。
我正在使用以下代码的bootstrap作为表单内的单选按钮
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" name="att" class="btn btn-primary active">Present</button>
<button type="button" name="att" class="btn btn-primary">Absent</button>
<button type="button" name="att" class="btn btn-primary">Leave</button>
</div>
Run Code Online (Sandbox Code Playgroud)
您可以访问http://getbootstrap.com/2.3.2/javascript.html#buttons找到无线电示例
我使用这个来进行员工出勤,因此有多个员工记录,并且会有一个阵列.我试过问题获取twitter bootstrap单选按钮的价值.JQuery 但这只返回我最后选择的值.
我怎么解决这个?
注意:我也尝试过输入标签而不是按钮但是效果造型
我试图在delim"//"上打破字符串.我的字符串也包含"/"和StringTokenizer给出奇怪的结果,它也打破了"/"上的字符串.
String mStr = "abcd//aaa//32434//3/34343";
StringTokenizer tok = new StringTokenizer(mStr, "//");
while(tok.hasMoreTokens()){
System.out.println(tok.nextToken());
}
Run Code Online (Sandbox Code Playgroud)
结果是
abcd
aaa
32434
3
34343
Run Code Online (Sandbox Code Playgroud)
而预期的结果是
abcd
aaa
32434
3/34343
Run Code Online (Sandbox Code Playgroud)
为什么会这样,它的解决方案是什么?我不想用其他字符替换"/".