当前位置: 首页>>代码示例>>Java>>正文


Java Message.getContent方法代码示例

本文整理汇总了Java中com.google.android.gms.nearby.messages.Message.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getContent方法的具体用法?Java Message.getContent怎么用?Java Message.getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.nearby.messages.Message的用法示例。


在下文中一共展示了Message.getContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveFoundMessage

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
/**
 * Saves a message string to {@link SharedPreferences}.
 *
 * @param context The context.
 * @param message The Message whose payload (as string) is saved to SharedPreferences.
 */
static void saveFoundMessage(Context context, Message message) {
    ArrayList<String> cachedMessages = new ArrayList<>(getCachedMessages(context));
    Set<String> cachedMessagesSet = new HashSet<>(cachedMessages);
    String messageString = new String(message.getContent());
    if (!cachedMessagesSet.contains(messageString)) {
        cachedMessages.add(0, new String(message.getContent()));
        getSharedPreferences(context)
                .edit()
                .putString(KEY_CACHED_MESSAGES, new Gson().toJson(cachedMessages))
                .apply();
    }
}
 
开发者ID:googlecodelabs,项目名称:hello-beacons,代码行数:19,代码来源:Utils.java

示例2: onFound

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
@Override
public void onFound(final Message message) {
  String json = new String(message.getContent());
  final NearbyPerson person = GSON.fromJson(json, NearbyPerson.class);
  runOnUiThread(new Runnable() {
    @Override
    public void run() {
      addPerson(person);
      updateList();
    }
  });
}
 
开发者ID:chiuki,项目名称:friendspell,代码行数:13,代码来源:BaseNearbyActivity.java

示例3: OfferBeacon

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
public OfferBeacon(Message message) {
    if (!TYPE.equals(message.getType())) {
        throw new IllegalArgumentException(
                "Incorrect beacon message type: " + message.getType());
    }

    String json = new String(message.getContent());
    try {
        JSONObject parsed = new JSONObject(json);
        section = parsed.getString("section");
        offer = parsed.getString("latest_offer");
    } catch (JSONException e) {
        throw new IllegalArgumentException("Invalid JSON Contents");
    }
}
 
开发者ID:devunwired,项目名称:nearby-beacons,代码行数:16,代码来源:OfferBeacon.java

示例4: onFound

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
@Override
public void onFound(Message message) {
    String nearbyMessage = new String(message.getContent(), Charset.forName("UTF-8"));
    Log.v(TAG, "Found message: " + message.getNamespace());
    displayNotification(message);
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:7,代码来源:BeaconsFragment.java

示例5: onLost

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
@Override
public void onLost(Message message) {
    String nearbyMessage = new String(message.getContent(), Charset.forName("UTF-8"));
    Log.v(TAG, "Lost message: " + nearbyMessage);
    updateNotification(message);
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:7,代码来源:BeaconsFragment.java

示例6: getView

import com.google.android.gms.nearby.messages.Message; //导入方法依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = mInflator.inflate(R.layout.listitem_device, null);
        viewHolder = new ViewHolder();
        viewHolder.tvAttachment = (TextView) convertView.findViewById(R.id.attachment_message);
        viewHolder.tvNamespace = (TextView) convertView.findViewById(R.id.namespace_message);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    Message message = nearbyDeviceMessageList.get(position);
    String namespace = message.getNamespace();
    final String attachment = new String(message.getContent(), Charset.forName("UTF-8"));
    SpannableString attachmentContent = null;
    if(attachment.startsWith("http")) {
        attachmentContent = new SpannableString(attachment);
        attachmentContent.setSpan(new UnderlineSpan(), 0, attachment.length(), 0);
        viewHolder.tvAttachment.setText(attachmentContent);
    } else {
        viewHolder.tvAttachment.setText(attachment);
    }
    if (namespace != null && namespace.length() > 0)
        viewHolder.tvNamespace.setText(namespace);
    //viewHolder.projectId.setText(attachment);

    if(attachmentContent != null && attachmentContent.toString().startsWith("http")) {
        //viewHolder.projectId.setPaintFlags(viewHolder.projectId.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        viewHolder.tvAttachment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(attachment));
                context.startActivity(browserIntent);
            }
        });
    } else {
        viewHolder.tvAttachment.setOnClickListener(null);
    }

    return convertView;
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:45,代码来源:EddystoneBeaconsAdapter.java


注:本文中的com.google.android.gms.nearby.messages.Message.getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。