小编Ahm*_*ani的帖子

如何将数据传递给BroadcastReceiver?

我想要做的是我的应用程序向其发送消息的数字被传递给BraodcastReceiver ...但到目前为止我要么为null或者BroadcastReceiver只是简单地崩溃..

这是我对CreateMessage类的BroadcastReceiver的意图......

        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putString("phN", phoneNo);
        intent.putExtras(bundle);
        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

在BroadcastReceiver(SmsReceiver类)中,我试图抓住这样的意图..

public void onReceive(Context context, Intent intent) {
    //---get the SMS message passed in---
    Bundle bundle = intent.getExtras();
    try{
    //receiveNumbers = intent.getExtras().get("phN").toString();
        String  receiveNumbers = intent.getStringExtra("phN");
        Toast.makeText(context, receiveNumbers, Toast.LENGTH_LONG).show();
    }catch(Exception e){
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.AEM_n"
      android:versionCode="2" android:versionName="2.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.READ_SMS"/>    
    <uses-permission  android:name="android.permission.SEND_SMS"/>
    <uses-permission  android:name="android.permission.RECEIVE_SMS"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
        <activity android:name=".new_menu"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" …
Run Code Online (Sandbox Code Playgroud)

string sms android broadcastreceiver android-intent

16
推荐指数
1
解决办法
6万
查看次数

Windows上的Hadoop安装问题

我一直试图Hadoop在Windows 7 上安装很长一段时间.我正在关注此博客以获取相关说明.但不幸的是,我还没有能够运行Namenode.hdfs-site.xml文件似乎有问题,但我没有看到任何错误.请看一下

HDFS-site.xml中

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
   <property>
       <name>dfs.replication</name>
       <value>1</value>
   </property>
   <property>
       <name>dfs.namenode.name.dir</name>
       <value>F:\hadoop-2.7.2\data\namenode</value>
   </property>
   <property>
       <name>dfs.datanode.data.dir</name>
     <value>F:\hadoop-2.7.2\data\datanode</value>
   </property>
</configuration>
Run Code Online (Sandbox Code Playgroud)

和我hdfs namenode -format在命令提示符下运行命令时得到的错误日志:

C:\Users\ABC>hdfs namenode -format
Hadoop common not found.
16/08/05 12:44:53 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = ABC-PC/172.20.0.51
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.7.2
STARTUP_MSG:   classpath = F:\hadoop-2.7.2\etc\hadoop;F:\hadoop-2.7.2\share\hado
op\common\lib\commons-compress-1.4.1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib
\jersey-server-1.9.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\jets3t-0.9.0.jar;
F:\hadoop-2.7.2\share\hadoop\common\lib\jersey-core-1.9.jar;F:\hadoop-2.7.2\shar
e\hadoop\common\lib\hadoop-auth-2.7.2.jar;F:\hadoop-2.7.2\share\hadoop\common\li
b\commons-digester-1.8.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\log4j-1.2.17.
jar;F:\hadoop-2.7.2\share\hadoop\common\lib\java-xmlbuilder-0.4.jar;F:\hadoop-2.
7.2\share\hadoop\common\lib\curator-client-2.7.1.jar;F:\hadoop-2.7.2\share\hadoo
p\common\lib\jetty-util-6.1.26.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\xmlen
c-0.52.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\activation-1.1.jar;F:\hadoop-
2.7.2\share\hadoop\common\lib\jackson-core-asl-1.9.13.jar;F:\hadoop-2.7.2\share\
hadoop\common\lib\jaxb-impl-2.2.3-1.jar;F:\hadoop-2.7.2\share\hadoop\common\lib\ …
Run Code Online (Sandbox Code Playgroud)

windows hadoop namenode

9
推荐指数
1
解决办法
4814
查看次数

如何使用 Android SDK 刷新 AWS Cognito 中的令牌?

我一直在寻找在AWS作为联合身份生成的令牌过期后刷新令牌的正确方法。我的应用程序使用 cognito 来记录、注册用户,然后Access Token使用RetroFit.

改造电话

 HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
        //end

        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        httpClient.readTimeout(45, TimeUnit.SECONDS);
        httpClient.connectTimeout(120, TimeUnit.SECONDS);
        httpClient.interceptors().add(new AuthInterceptor());
        httpClient.addInterceptor(interceptor); //debugging

        httpClient.addInterceptor(new Interceptor() {
            @Override
            public Response intercept(Chain chain) throws IOException {
                Request original = chain.request();

                // Customize the request
                Request request = original.newBuilder()
                        .header("Content-type", "application/json")
                        .header("Authorization", "auth-token")
                        .header("Accept", "application/json")
                        .header("deviceType", "android") //experimental
                        .header("Version", "v1")
                        .method(original.method(), original.body())
                        .build();

                Response response = chain.proceed(request);
                return response;
            }
        });

        Retrofit …
Run Code Online (Sandbox Code Playgroud)

android amazon-web-services amazon-cognito

3
推荐指数
1
解决办法
3284
查看次数