공유 의도에서 링크를 갖고 싶습니다. 크롬을 통해 링크를 받으면 형식이 올바르지 만 때로는 다른 앱도 텍스트를 추가합니다.Android : 문자열 값에서 링크 추출
예 :
크롬 : "www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play"
트위터 : "얘들 아 체크 아웃 이 링크는 정말 멋지다. https://www.recode.net/2016/7/21/12243560/google-machine-learning-comics-play "
트위터의 경우 모든 컨텍스트를 없애고 링크 만 남기고 싶습니다. 즉, www.recode.net/2016/7/21/12243560/ google-machine-learning-comics-play
참고 : 링크의 형식은 https : // .. (또는) www가 될 수 있습니다. .. (또는) recode.net/... (처음에는 www가 없습니다).
이것을 정정하는 정규식은 무엇입니까?
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareintent);
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null)
{
if ("text/plain".equals(type))
{
// Handle text being sent
handleSendText(intent);
}
}
}
void handleSendText(Intent intent)
{
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null)
{
// Update UI to reflect text being shared
TextView tvShare = (TextView) findViewById(R.id.tvShare);
tvShare.setText(sharedText);
}
}
당신은 하나 이상 포함 된 문자열을 검색 할 수 있습니다를 어쩌면 4 자? (공백없이) –
이 코드는 어떻게 관련이 있습니까?/지금까지 시도한 것은 무엇입니까? – njzk2